setCursor without disabling selection

ATM, setCursor “Will replace all selections with a single, empty selection at the given position”.

Is there, or can we have a way to disable this behavior for a particular setCursor ?

Case in point - implementing a ‘search in selection’. When moving to the next match in a selection I want to keep the selection.

I tried resetting the selection after setCursor with setSelections but that moves the cursor to the end of the selection :frowning:

(I’m using showCursorWhenSelecting: true)

Thx!

Nope, that’s not supported. It would be completely at odds with CodeMirror’s selection model. You could maybe use markText to show the range you’re reaching, and use the selection to point at the current match.

Thx marjin,

Sorry but I don’t fully understand, how is it at odds ?

Can you at least provide a way to prevent setSelection/s from moving the cursor to the end of the selection they set ? this ‘feature’ is not even documented …

search/replace in selection is a common code editor feature, I would like to actually move the cursor inside the selection, not only mark a range.

can you help ?

A cursor is a type of selection. I don’t understand what you are asking.

A cursor is a type of selection ? I’m confused :frowning:

I want to put the cursor (that is the blinking or static vertical line) at a particular line/ch location which happens to be inside a selection, while keeping the selection.

so as the user presses F3 the cursor keeps jumping to the next match within the selection while the selection remains.

(I will then remove the selection on any change or movement other than F3 for example)

Yes, and that is what you can’t do, because selection’s can’t overlap.