Skip to content

Commit 33d915e

Browse files
Fix matching brace not returning left
1 parent f74a512 commit 33d915e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/buffer/buffer.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,12 @@ func (b *Buffer) findMatchingBrace(braceType [2]rune, start Loc, char rune) (Loc
13861386
// for given starting location but it was found for the location one character left
13871387
// of it. The third returned value is true if the matching brace was found at all.
13881388
func (b *Buffer) FindMatchingBrace(start Loc) (Loc, bool, bool) {
1389-
start = b.resolveBraceStartLoc(start)
1389+
newstart := b.resolveBraceStartLoc(start)
1390+
var left bool = false
1391+
if start != newstart {
1392+
left = true
1393+
start = newstart
1394+
}
13901395
curLine := []rune(string(b.LineBytes(start.Y)))
13911396

13921397
if start.X >= 0 && start.X < len(curLine) {
@@ -1395,7 +1400,7 @@ func (b *Buffer) FindMatchingBrace(start Loc) (Loc, bool, bool) {
13951400
if startChar == bp[0] || startChar == bp[1] {
13961401
mb, found := b.findMatchingBrace(bp, start, startChar)
13971402
if found {
1398-
return mb, false, true
1403+
return mb, left, true
13991404
}
14001405
}
14011406
}

0 commit comments

Comments
 (0)