Skip to content

Commit 28309a7

Browse files
author
berquerant
committed
go fix
1 parent 1edab1e commit 28309a7

2 files changed

Lines changed: 2 additions & 9 deletions

File tree

bytes.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,8 @@ func (b Bytes) Adjacency(line, column, count int) (*Adjacency, bool) {
107107
}
108108
focus := target[column-1]
109109

110-
start := column - 1 - count
111-
if start < 0 {
112-
start = 0
113-
}
114-
end := column + count
115-
if end >= len(target) {
116-
end = len(target)
117-
}
110+
start := max(column-1-count, 0)
111+
end := min(column+count, len(target))
118112
targetString := string(target[start:end])
119113
return &Adjacency{
120114
Linum: line,

lexer_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ func TestLexer(t *testing.T) {
149149
),
150150
},
151151
} {
152-
tc := tc
153152
t.Run(tc.title, func(t *testing.T) {
154153
s := ybase.NewLexer(ybase.NewScanner(ybase.NewReader(bytes.NewBufferString(tc.input), slog.Info), tc.scan))
155154
got := []ybase.Token{}

0 commit comments

Comments
 (0)