scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.65k stars 192 forks source link

Modify Selection #215

Closed kushagrawal071 closed 3 years ago

kushagrawal071 commented 3 years ago

Hi, I am trying to modify the selection below : <CodeMirror [...] selection={{ ranges: [{ anchor: {ch: 8, line: 5}, head: {ch: 37, line: 5} }], focus: true // defaults false if not specified }} onSelection={(editor, data) => {}} />

I keep the selection ranges in the state right now, but when the state is updated it's not changed.

I am trying to create a code correlation kind of thing where I have to modify the selection in one window by clicking on the gutter of another window.

Any suggestions on how I can do this?

elijahjcobb commented 3 years ago

I am having the same issue and can replicate with version 7.2.1.

kushagrawal071 commented 3 years ago

I worked around by adding key=Date.now() in CodeMirror