making a widget stick to the end of a line

I’m using setBookmark with the insertLeft option to put a widget at the end of a line. It mostly works but there’s a slight annoyance: entering a newline at the end of the line (to the left of the widget) moves the widget to the next (blank) line along with the cursor.

This is logically consistent with the behavior when inserting other characters, but it would be nicer if the widget would stick to the line it’s on. Is there some way to treat a newline specially, so that typing a newline puts the newline character to the right of the widget?

Nope, but you could register a "change" event handler that detects this situation and moves the widget back to the previous line when it occurs. It’ll be called before the screen updates, so the user wouldn’t see anything.