I’ve wasted some time in the past trying to figure out how full_line works and here’s what I’ve come up with:
def lskip_nonewlines(text, pt):
len_text = len(text)
if pt < 0:
return pt
while True:
if pt <= 0 or pt >= len_text:
break
if text[pt - 1] == "\n":
break
pt -= 1
return pt
def rskip_nonewlines(text, pt):
len_text = len(text)
if pt < 0:
pt = 0
while True:
if pt >= len_text:
break
if text[pt] == "\n":
break
pt += 1
return pt
def full_line(self, x):
region = Region(x)
text = self.text()
if region.a <= region.b:
region.a = lskip_nonewlines(text, region.a)
region.b = rskip_nonewlines(text, region.b)
region.b = region.b + 1 if region.b < len(text) else region.b
else:
region.a = rskip_nonewlines(text, region.a)
region.b = lskip_nonewlines(text, region.b)
region.a = region.a + 1 if region.a < len(text) else region.a
return Region(region.begin(), region.end())
In any case, as @kingkeith said, if you don’t like this behaviour there are zillions ways to achieve what you want… in fact, you’re not even forced to use full_line at all… which btw, no, it’s not buggy
As an analogy… saying full_line
is buggy it’s like suggesting that f(x) = x*x
is buggy because f(2)!=5
…
Ps. Speaking of which, gonna self-promote a SO thread I’d opened related to a similar subject https://stackoverflow.com/questions/56025185/how-does-full-line-works-in-sublimetext/56027488