Skip to content

Commit

Permalink
fix: clamp diagnostic line number to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg committed Jul 20, 2023
1 parent f8a94ec commit d634a8b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/next_ls/extensions/elixir_extension.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ defmodule NextLS.ElixirExtension do
defp range({start_line, start_col, end_line, end_col}) do
%GenLSP.Structures.Range{
start: %GenLSP.Structures.Position{
line: start_line - 1,
line: clamp(start_line - 1),
character: start_col - 1
},
end: %GenLSP.Structures.Position{
line: end_line - 1,
line: clamp(end_line - 1),
character: end_col - 1
}
}
Expand All @@ -70,11 +70,11 @@ defmodule NextLS.ElixirExtension do
defp range({line, col}) do
%GenLSP.Structures.Range{
start: %GenLSP.Structures.Position{
line: line - 1,
line: clamp(line - 1),
character: col - 1
},
end: %GenLSP.Structures.Position{
line: line - 1,
line: clamp(line - 1),
character: 999
}
}
Expand All @@ -83,13 +83,15 @@ defmodule NextLS.ElixirExtension do
defp range(line) do
%GenLSP.Structures.Range{
start: %GenLSP.Structures.Position{
line: line - 1,
line: clamp(line - 1),
character: 0
},
end: %GenLSP.Structures.Position{
line: line - 1,
line: clamp(line - 1),
character: 999
}
}
end

def clamp(line), do: max(line, 0)
end

0 comments on commit d634a8b

Please sign in to comment.