Skip to content

Commit

Permalink
fix(references): clamp line and column numbers
Browse files Browse the repository at this point in the history
Fixes #141
  • Loading branch information
mhanberg committed Aug 8, 2023
1 parent 5a3b530 commit 55ead79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ defmodule NextLS do
%Location{
uri: "file://#{file}",
range: %Range{
start: %Position{line: start_line - 1, character: start_column - 1},
end: %Position{line: end_line - 1, character: end_column - 1}
start: %Position{line: clamp(start_line - 1), character: clamp(start_column - 1)},
end: %Position{line: clamp(end_line - 1), character: clamp(end_column - 1)}
}
}
end
Expand Down Expand Up @@ -712,4 +712,5 @@ defmodule NextLS do
end
end
end
defp clamp(line), do: max(line, 0)
end

0 comments on commit 55ead79

Please sign in to comment.