Page MenuHome

Text editor API needs a 'select_end_line_index' attribute to expose selection to the user.
Closed, ResolvedPublic



As reported in this BA thread
There's one attribute missing to be able to perform actions relative to a multiline selection.

Here is the attibute list :

current_character   # character position (at selection character start)

current_line   # line object where cursor is (at selection start)

current_line_index    # index where cursor is (at selection start)

select_end_character   # character position at selection end

select_end_line   # line object where selection end (but no index accessible)

!! MISSING !! >> select_end_line_index (impossible to know where the selection end)

Maybe I missed a way to get the selection directly ? (so we can count the '\n' as a workaround without using 'bpy.ops.text.copy()' that overwrite clipboard)

PS : I did not know who to assign so I chose you Jacques since you wrote code-autocomplete and should be familliar with text editor, I'm sorry if you're not the right guy to bother.


To Do

Event Timeline

I have an old addon (which is outdated) that was handling text selection with no problems:

Samuel Bernou (Pullup) closed this task as Resolved.Jul 3 2019, 10:38 AM

Nice !
I didn't thought to compare line object itself against select_end_line.
Someone also gave me this solution on BA thread "Get / set character and line coordinate of the selection in the text editor".
Thanks for the digging.