orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
636 stars 38 forks source link

V12 buffer.current_pos nil in block comments #421

Closed merlindiavova closed 1 year ago

merlindiavova commented 1 year ago

Hi, Given block comment below, is not normal for the buffer.current_pos to be nil?

--[[
Some text
--]]
orbitalquark commented 1 year ago

buffer.current_pos should never be nil.

merlindiavova commented 1 year ago

I thought as much, for some reason, when the caret is within the block comments it reports buffer.current_pos as nil.

I'm using a Linux machine, will check later on my Mac

ClaudioGi commented 1 year ago

The current position is the distance in bytes of the caret position from the beginning of the currently viewed document starting with one. So no matter where in the code, the current position is 1 if the Caret is at the very beginning of the buffer or larger, but never nil. Try to put following line at the beginning of the file (into the first line):

㑖㑖㑖㑖㑖

and then test which position is reported if you put the caret at the line end (press Ctrl+e and type 'buffer.current_pos` plus Enter. There are five characters behind the caret/cursor but the reported position will be 16 ( 1 + 5*3 bytes for the utf-8 code of the Unicode point of the character).

By the way: you can close the issue clicking on the appropriate button at the bottom of this page as the information provided up to now seem to have solved the problem you were facing.

merlindiavova commented 1 year ago

Thanks @ClaudioGi and @orbitalquark