Only highlight matching brace if one is found

Fixes #1505
This commit is contained in:
Zachary Yedidia
2020-02-12 01:32:23 -05:00
parent 5e9c6375d0
commit 6588f02f7b
3 changed files with 22 additions and 16 deletions

View File

@@ -1060,11 +1060,15 @@ func (h *BufPane) JumpToMatchingBrace() bool {
r := h.Cursor.RuneUnder(h.Cursor.X)
rl := h.Cursor.RuneUnder(h.Cursor.X - 1)
if r == bp[0] || r == bp[1] || rl == bp[0] || rl == bp[1] {
matchingBrace, left := h.Buf.FindMatchingBrace(bp, h.Cursor.Loc)
if left {
h.Cursor.GotoLoc(matchingBrace)
matchingBrace, left, found := h.Buf.FindMatchingBrace(bp, h.Cursor.Loc)
if found {
if left {
h.Cursor.GotoLoc(matchingBrace)
} else {
h.Cursor.GotoLoc(matchingBrace.Move(1, h.Buf))
}
} else {
h.Cursor.GotoLoc(matchingBrace.Move(1, h.Buf))
return false
}
}
}