Skip to content

Commit 63e0467

Browse files
committed
don't crash on broken diagnostics
1 parent 02c348a commit 63e0467

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/language_server/lib/language_server/diagnostics.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
327327
# we return a 0 length range exactly at that location
328328
defp range({line_start, char_start}, source_file)
329329
when not is_nil(source_file) do
330+
# some diagnostics are broken
331+
line_start = line_start || 1
332+
char_start = char_start || 1
330333
lines = SourceFile.lines(source_file)
331334
# elixir_position_to_lsp will handle positions outside file range
332335
{line_start_lsp, char_start_lsp} =
@@ -348,6 +351,13 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
348351
# we return exactly that range
349352
defp range({line_start, char_start, line_end, char_end}, source_file)
350353
when not is_nil(source_file) do
354+
# some diagnostics are broken
355+
line_start = line_start || 1
356+
char_start = char_start || 1
357+
358+
line_end = line_end || 1
359+
char_end = char_end || 1
360+
351361
lines = SourceFile.lines(source_file)
352362
# elixir_position_to_lsp will handle positions outside file range
353363
{line_start_lsp, char_start_lsp} =

0 commit comments

Comments
 (0)