Skip to content

Set both selection and caret in Generic Code Editor #2958

Answered by mickaelistria
danthe1st asked this question in Q&A
Discussion options

You must be logged in to vote

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 used sourceViewer.getTextWidget().setSelection() with start > end or setSelectionRanges with negative length to build such selections.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@laeubi
Comment options

laeubi May 6, 2025
Collaborator

@mickaelistria
Comment options

@laeubi
Comment options

laeubi May 6, 2025
Collaborator

@danthe1st
Comment options

Answer selected by danthe1st
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants