Document.currentLine

I’m trying to retrieve the size of the currently selected line in a document. I’m failing…
It seems that Document ignores the blank lines or something.

// use the arrow keys to move up and down
Document.globalKeyUpAction_({|doc, key|
	
	Document.current.currentLine.postln;
	
	
	Document.current.currentLine.size.postln;
});

Also try moving around on a line using the left and right arrow keys. Really strange results i think. Is this a bug?

Hm. The first code example actually works if it’s there are no strange characters in the document. This problem seems to be related to the “§” character in my document and probably the fact that “§”.size == 2. Each “§” causes an offset in the currentLine and selectLine methods apparently. I guess this is not how it should behave?

// other random stuff including the § character
§
§

§

(
Document.globalKeyUpAction_({|doc, key|
	Document.current.currentLine.postln;
});
)

Document.current.selectLine(5)

The support code for currentLine is here: https://github.com/supercollider/supercollider/blob/79c9d77f3946a3caf49fc0522319b52acd51878d/SCClassLibrary/scide_scqt/ScIDE.sc#L848

I’d have to guess that maybe selectionStart is being reported in character units (1 multibyte character = 1 character) while sclang string processing is in byte units (1 multibyte character = 2 or more bytes).

I’m not sure how to solve this.

hjh