techee/geany-lsp

Investigate how to cancel multiple carets on move

Closed this issue · 4 comments

For Latex

\begin{$1}

\end{$1}

multiple carets can be added at the $1 positions to edit the two values simultaneously. However, when moving up/down using keyboard arrows, all the carets move up/down. It would make more sense to disable multiple carets when keyboard arrow event happens but I'm not sure how to do it with Scintilla.

What happens is this:

  1. User selects autocompletion item
Screenshot 2024-09-11 at 0 52 52
  1. \begin{} \end{} is inserted and two carets are placed inside {} so editing happens simultaneously
Screenshot 2024-09-11 at 0 53 39
  1. User is done with editing inside {} so he presses arrow down to start editing the text in the block - what happens is this
Screenshot 2024-09-11 at 0 54 01

where both carets still exist. What I'd like to do is to keep only the primary caret. How can I detect arrow key presses to cancel multiple carets?

There is SCN_UPDATEUI with SC_UPDATE_SELECTION that probably gets fired but I guess it also gets fired when the caret moves as a result of inserting text so it won't detect arrow presses only.

@nyamatongwe Any idea?

Alright, I think I could just intercept GTK keypress events and do SCI_CANCEL when arrows are pressed if there's not a better way.

Alright, I think I could just intercept GTK keypress events and do SCI_CANCEL when arrows are pressed if there's not a better way.

Done this way.

SCN_UPDATEUI is less specific than key monitoring but there are many keys bound to actions which may need to cancel.