Skip to content

Commit

Permalink
Remove extra bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed May 2, 2024
1 parent 37c1600 commit d9cdd41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bindings/go/scip/source_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (d *SourceFile) String() string {
// RangeText returns the substring of the source file contents that enclose the provided range.
func (d *SourceFile) RangeText(position Range) string {
result := strings.Builder{}
for line := position.Start.Line; line <= position.End.Line && int(line) < len(d.Lines); line++ {
for line := position.Start.Line; line <= position.End.Line; line++ {
start := position.Start.Character
if line > position.Start.Line {
result.WriteString("\n")
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/scip/source_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestRangeText(t *testing.T) {
{range_: []int32{0, 0, 0, 8}, expect: autogold.Expect("Mary had")},
{range_: []int32{0, 0, 1, 0}, expect: autogold.Expect("Mary had a little lamb,\n")},
{range_: []int32{0, 0, 1, 10}, expect: autogold.Expect("Mary had a little lamb,\nIts fleece")},
{range_: []int32{0, 0, 5, 0}, expect: autogold.Expect(`Mary had a little lamb,
{range_: []int32{0, 0, 4, 0}, expect: autogold.Expect(`Mary had a little lamb,
Its fleece was white as snow.
And everywhere that Mary went,
The lamb was sure to go.
Expand Down

0 comments on commit d9cdd41

Please sign in to comment.