Skip to content

Commit 586a935

Browse files
committed
fix crash on invalid diagnostic severity
1 parent a7151bf commit 586a935

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

apps/language_server/lib/language_server/diagnostics.ex

+19-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
44
from various sources
55
"""
66
alias ElixirLS.LanguageServer.{SourceFile, JsonRpc}
7+
require Logger
78

89
@enforce_keys [:file, :severity, :message, :position, :compiler_name]
910
defstruct [
@@ -314,10 +315,24 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
314315
for %__MODULE__{} = diagnostic <- uri_diagnostics do
315316
severity =
316317
case diagnostic.severity do
317-
:error -> 1
318-
:warning -> 2
319-
:information -> 3
320-
:hint -> 4
318+
:error ->
319+
1
320+
321+
:warning ->
322+
2
323+
324+
:information ->
325+
3
326+
327+
:hint ->
328+
4
329+
330+
other ->
331+
Logger.warn(
332+
"Invalid severity on diagnostic: #{inspect(other)}, using warning level"
333+
)
334+
335+
2
321336
end
322337

323338
%{

apps/language_server/lib/language_server/providers/on_type_formatting.ex

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ defmodule ElixirLS.LanguageServer.Providers.OnTypeFormatting do
4949
{:ok, nil}
5050
end
5151
end
52+
5253
def format(%SourceFile{} = _source_file, _line, _character, _, _options) do
5354
{:ok, nil}
5455
end

0 commit comments

Comments
 (0)