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

@@ -452,12 +452,14 @@ func (w *BufWindow) displayBuffer() {
r := c.RuneUnder(curX)
rl := c.RuneUnder(curX - 1)
if r == bp[0] || r == bp[1] || rl == bp[0] || rl == bp[1] {
mb, left := b.FindMatchingBrace(bp, curLoc)
matchingBraces = append(matchingBraces, mb)
if !left {
matchingBraces = append(matchingBraces, curLoc)
} else {
matchingBraces = append(matchingBraces, curLoc.Move(-1, b))
mb, left, found := b.FindMatchingBrace(bp, curLoc)
if found {
matchingBraces = append(matchingBraces, mb)
if !left {
matchingBraces = append(matchingBraces, curLoc)
} else {
matchingBraces = append(matchingBraces, curLoc.Move(-1, b))
}
}
}
}