Handle backspaces for visible width

This makes it so we treat backspaces as width -1, but never go below a
0 total width when talking about *lines*, like in screen or string
length --visible.

Fixes #8277.
This commit is contained in:
Fabian Homborg
2021-09-23 12:57:44 +02:00
parent 85ea9bf781
commit bb115c847e
5 changed files with 66 additions and 18 deletions

View File

@@ -112,6 +112,23 @@ string length --visible a(set_color blue)b\ncde
# CHECK: 2
# CHECK: 3
# Backslashes and visible length:
# It can't move us before the start of the line.
string length --visible \b
# CHECK: 0
# It can't move us before the start of the line.
string length --visible \bf
# CHECK: 1
# But it does erase chars before.
string length --visible \bf\b
# CHECK: 0
# Never move past 0.
string length --visible \bf\b\b\b\b\b
# CHECK: 0
string sub --length 2 abcde
# CHECK: ab