Fix matchbraceleft option

Fixes #1101
This commit is contained in:
Zachary Yedidia
2018-04-28 17:42:17 -04:00
parent 2e64499f96
commit 53e142fb88

View File

@@ -73,20 +73,18 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
// bracePairs is defined in buffer.go
if buf.Settings["matchbrace"].(bool) {
for _, bp := range bracePairs {
if buf.Cursor.RuneUnder(buf.Cursor.X) == bp[0] {
matchingBrace = buf.FindMatchingBrace(bp, buf.Cursor.Loc)
break
}
left := buf.Cursor.Loc.X
curX := buf.Cursor.X
curLoc := buf.Cursor.Loc
if buf.Settings["matchbraceleft"].(bool) {
left -= 1
if left < 0 {
left = 0
curX--
if curX > 0 {
curLoc = curLoc.Move(-1, buf)
}
}
if buf.Cursor.RuneUnder(left) == bp[1] {
matchingBrace = buf.FindMatchingBrace(
bp, Loc{X: left, Y: buf.Cursor.Loc.Y})
r := buf.Cursor.RuneUnder(curX)
if r == bp[0] || r == bp[1] {
matchingBrace = buf.FindMatchingBrace(bp, curLoc)
}
}
}