Skip to content

Commit 5af6a3f

Browse files
committed
fix crash introduced in ff130f3
1 parent ff130f3 commit 5af6a3f

File tree

1 file changed

+4
-4
lines changed
  • apps/language_server/lib/language_server

1 file changed

+4
-4
lines changed

apps/language_server/lib/language_server/build.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ defmodule ElixirLS.LanguageServer.Build do
286286
# position is a 1 based line number
287287
# we return a range of trimmed text in that line
288288
defp range(position, source_file)
289-
when is_integer(position) and position >= 1 and is_binary(source_file) do
289+
when is_integer(position) and position >= 1 and not is_nil(source_file) do
290290
# line is 1 based
291291
line = position - 1
292292
text = Enum.at(SourceFile.lines(source_file), line) || ""
@@ -309,7 +309,7 @@ defmodule ElixirLS.LanguageServer.Build do
309309
# position is a 1 based line number and 0 based character cursor (UTF8)
310310
# we return a 0 length range exactly at that location
311311
defp range({line_start, char_start}, source_file)
312-
when line_start >= 1 and is_binary(source_file) do
312+
when line_start >= 1 and not is_nil(source_file) do
313313
lines = SourceFile.lines(source_file)
314314
# line is 1 based
315315
start_line = Enum.at(lines, line_start - 1)
@@ -331,7 +331,7 @@ defmodule ElixirLS.LanguageServer.Build do
331331
# position is a range defined by 1 based line numbers and 0 based character cursors (UTF8)
332332
# we return exactly that range
333333
defp range({line_start, char_start, line_end, char_end}, source_file)
334-
when line_start >= 1 and line_end >= 1 and is_binary(source_file) do
334+
when line_start >= 1 and line_end >= 1 and not is_nil(source_file) do
335335
lines = SourceFile.lines(source_file)
336336
# line is 1 based
337337
start_line = Enum.at(lines, line_start - 1)
@@ -355,7 +355,7 @@ defmodule ElixirLS.LanguageServer.Build do
355355

356356
# position is 0 which means unknown
357357
# we return the full file range
358-
defp range(0, source_file) when is_binary(source_file) do
358+
defp range(0, source_file) when not is_nil(source_file) do
359359
SourceFile.full_range(source_file)
360360
end
361361

0 commit comments

Comments
 (0)