Skip to content

Commit

Permalink
increase compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Feb 7, 2024
1 parent ef84c8b commit d4f7e71
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions apps/language_server/lib/language_server/ast_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ defmodule ElixirLS.LanguageServer.AstUtils do
end

lines = SourceFile.lines(literal)
{line + length(lines), meta[:indentation] + get_delimiter_length(delimiter)}
# meta[:indentation] is nil on 1.12
indentation = Keyword.get(meta, :indentation, 0)

{line + length(lines), indentation + get_delimiter_length(delimiter)}
else
get_literal_end(literal, {line, column}, delimiter)
end
Expand Down Expand Up @@ -194,13 +197,18 @@ defmodule ElixirLS.LanguageServer.AstUtils do
form == :__aliases__ ->
last = meta[:last]

last_length =
case List.last(args) do
atom when is_atom(atom) -> atom |> to_string() |> String.length()
_ -> 0
end
if last do
last_length =
case List.last(args) do
atom when is_atom(atom) -> atom |> to_string() |> String.length()
_ -> 0
end

{last[:line] - 1, last[:column] - 1 + last_length}
{last[:line] - 1, last[:column] - 1 + last_length}
else
# last is nil on 1.12
get_eoe_by_formatting(ast, {line, column})
end

form == :% and match?([_, _], args) ->
[_alias, map] = args
Expand Down

0 comments on commit d4f7e71

Please sign in to comment.