How to mark the last part of line ?

I use markText() function to underline some characters in a line and indicate errors to end user.

I would like to underline the very last part of the line :

some example
            ^ underline this (which is usually line return)

this would give: 
some example_

The main issue is that the part I want to underline/mark does not exist as a character of the line. The only possibility would be for the line to end up with an extra space which is not the case.

If there’s no text there, you indeed can’t mark it. You could add a bookmark with a widget there.

I have tried to use bookmark function (the widget is simply a <span>_</span> element).

It works but the widget prevent selecting the text correctly (eg: you click on widget by mistake and start dragging selection from there).

EDIT : what happen is the editor lose focus as soon as you click the widget (and thus stop responding to mouse events). It might be fixable.

Using the handleMouseEvents option to setBookmark might help with that.

This fixed the issue. Thanks a lot. We can close the topic :grinning: