Skip to content

Commit 08d73a8

Browse files
Fixing matching brackets not working when near string or comment
1 parent f593081 commit 08d73a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/buffer/buffer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"io/fs"
1111
"os"
1212
"path/filepath"
13+
"sort"
1314
"strconv"
1415
"strings"
1516
"sync"
1617
"sync/atomic"
1718
"time"
18-
"sort"
1919

2020
luar "layeh.com/gopher-luar"
2121

@@ -1157,17 +1157,17 @@ func (b *Buffer) GetSortedSyntaxGroupIndices(lineN int) []int {
11571157
// This optionally accepts sorted Group indices returned from GetSortedSyntaxGroupIndices()
11581158
// which can be reused on the same line.
11591159
func (b *Buffer) GetGroupAtLoc(loc Loc, sortedIndices []int) (highlight.Group, bool) {
1160-
if sortedIndices == nil {
1160+
if sortedIndices == nil {
11611161
sortedIndices = b.GetSortedSyntaxGroupIndices(loc.Y)
1162-
}
1162+
}
11631163
i := sort.SearchInts(sortedIndices, loc.X)
11641164
if i == 0 || i == len(sortedIndices) {
11651165
return 0, false
11661166
}
1167-
if sortedIndices[i] == loc.X && b.Match(loc.Y)[sortedIndices[i]] != 0 {
1167+
if sortedIndices[i] == loc.X {
11681168
return b.Match(loc.Y)[sortedIndices[i]], true
11691169
}
1170-
return b.Match(loc.Y)[sortedIndices[i - 1]], true
1170+
return b.Match(loc.Y)[sortedIndices[i-1]], true
11711171
}
11721172

11731173
func (b *Buffer) isLocInStringOrComment(loc Loc, sortedIndices []int) bool {
@@ -1217,7 +1217,7 @@ func (b *Buffer) findOpeningBrace(braceType [2]rune, start Loc) (Loc, bool) {
12171217
sortedGroups = b.GetSortedSyntaxGroupIndices(y)
12181218
sortedGroupsPopulated = true
12191219
}
1220-
if !b.isLocInStringOrComment(Loc{x, y}, sortedGroups) {
1220+
if !b.isLocInStringOrComment(Loc{x, y}, sortedGroups) {
12211221
i++
12221222
}
12231223
} else if r == braceType[0]{

0 commit comments

Comments
 (0)