Skip to content

Commit 2f5f6ed

Browse files
Fixing offset by 1 when matching brackets near string or comment
1 parent f593081 commit 2f5f6ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/buffer/buffer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ var BracePairs = [][2]rune{
11461146
func (b *Buffer) GetSortedSyntaxGroupIndices(lineN int) []int {
11471147
keys := make([]int, 0, len(b.Match(lineN)))
11481148
for k := range b.Match(lineN) {
1149-
keys = append(keys, k)
1149+
keys = append(keys, k + 1)
11501150
}
11511151
sort.Ints(keys)
11521152
return keys
@@ -1157,9 +1157,9 @@ 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
@@ -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)