JedWatson/react-codemirror

When pasting in multi-line values, it pastes twice

jonathon-neoswap opened this issue · 2 comments

Codesandbox: https://codesandbox.io/s/cranky-waterfall-7p4px8?file=/src/App.js

Copy the following:

[lib]
crate-type = ["cdylib"]

As you can see, the code pastes twice for some reason.

I am wondering if this has something to do with recoil...

Hey @jonathon-neoswap ,

I am new to this repo and was just going around the issues.
I just went through your code.
If we paste anything, the code pastes it twice.

This error can be removed by removing/commenting line number 55.
Here is the code that is changed:

<CodeMirror
        value={theCode}
        className="rounded-tl-lg rounded-bl-lg"
        height="100%"
        theme="dark"
        extensions={[
          EditorView.lineWrapping,
          FontSizeThemeExtension,
          rust(),
          // readOnlyRangesExtension(getReadOnlyRanges)  --> change
        ]}
        onChange={onChange}
        editable={isDisabled}
      />

By doing this, we don't get the same error.

Also as I am new to this repo, can you explain why we even need readOnlyRangesExtension.

Thank you!