Skip to content

Commit

Permalink
add comments on workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Feb 6, 2024
1 parent d46992a commit a238a27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions apps/language_server/lib/language_server/ast_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,16 @@ defmodule ElixirLS.LanguageServer.AstUtils do
{start_line, start_column} =
cond do
form == :%{} ->
# TODO elixir parser bug?
{line, column - 1}
column =
if Version.match?(System.version(), "< 1.16.2") do
# workaround elixir bug
# https://github.com/elixir-lang/elixir/commit/fd4e6b530c0e010712b06909c89820b08e49c238
column - 1
else
column
end

{line, column}

form == :-> and match?([[_ | _], _], args) ->
[[left | _], _right] = args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ defmodule ElixirLS.LanguageServer.Providers.SelectionRanges do
case AstUtils.node_range(ast) do
range(start_line, start_character, end_line, end_character) ->
start_character =
if form == :%{} and match?({:%, _, _}, parent_ast_from_stack) do
if form == :%{} and match?({:%, _, _}, parent_ast_from_stack) and
Version.match?(System.version(), "< 1.16.2") do
# workaround elixir bug
# https://github.com/elixir-lang/elixir/commit/fd4e6b530c0e010712b06909c89820b08e49c238
# undo column offset for structs inner map node
start_character + 1
else
Expand Down

0 comments on commit a238a27

Please sign in to comment.