Set both selection and caret in Generic Code Editor #2958
-
I am in the situation where the selection is set programmatically using the following: ISourceViewer sourceCiewer = ...;
sourceViewer.getSelectionProvider().setSelection(someSelextion); (or similar, e.g. However, this positions the caret (cursor) at the end of the selection but I want to position it differently. I tried to use For context: The selection is modified and is restored to its previous state causing a bug in wildwebdeveloper/lsp4e I want to get fixed and contributing it is the best way to actually get it done. Any other way of saving and restoring the selection including the caret would be a useful alternative as well. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I don't think the |
Beta Was this translation helpful? Give feedback.
I don't think the
getSelection()
API allows to get information about nor control the caret position, which makes sense since the getSelection() is about model more than widget. The caret position has to be set on widget level, you may have to usedsourceViewer.getTextWidget().setSelection()
with start > end orsetSelectionRanges
with negative length to build such selections.