mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 11:10:37 +03:00
bounds check on moveleft
This commit is contained in:
parent
02dc3753ac
commit
2c0775ad55
@ -627,13 +627,15 @@ func (b *Buffer) deleteBeforeCursor() {
|
||||
func (b *Buffer) moveLeft() {
|
||||
if b.curs.x == 0 && b.curs.y > 0 {
|
||||
b.curs.move(b.table.Lines[b.curs.y-1].Len(), -1)
|
||||
|
||||
} else if b.curs.x > 0 {
|
||||
str := b.table.Lines[b.curs.y].String()
|
||||
inBounds := (b.curs.x-1 >= 0 && b.curs.x-1 < len(str))
|
||||
|
||||
charWidth := 1
|
||||
str := b.table.Lines[b.curs.y].String()[b.curs.x-1]
|
||||
if str == '\t' {
|
||||
if inBounds && str[b.curs.x-1] == '\t' {
|
||||
charWidth = 4
|
||||
}
|
||||
|
||||
b.curs.moveRender(-1, 0, -charWidth, 0)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user