Skip to content

Commit

Permalink
no code action for potentially unformatted line
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldak committed Mar 14, 2024
1 parent 069cf41 commit e6c0089
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ defmodule ElixirLS.LanguageServer.Providers.CodeAction.Helpers do
is_line_formatted =
unformatted_text
|> Diff.diff(formatted_text)
|> Enum.filter(fn %TextEdit{range: range} ->
range["start"]["line"] == changed_line or range["end"]["line"] == changed_line
end)
|> Enum.filter(&near_changed_line(&1, changed_line))
|> Enum.empty?()

if is_line_formatted do
Expand All @@ -42,6 +40,13 @@ defmodule ElixirLS.LanguageServer.Providers.CodeAction.Helpers do
end
end

defp near_changed_line(%TextEdit{range: range}, changed_line) do
changed_line_neighborhood = [changed_line - 1, changed_line, changed_line + 1]

range["start"]["line"] in changed_line_neighborhood or
range["end"]["line"] in changed_line_neighborhood
end

@spec update_line(TextEdit.t(), non_neg_integer()) :: TextEdit.t()
def update_line(
%TextEdit{range: %{"start" => start_line, "end" => end_line}} = text_edit,
Expand Down

0 comments on commit e6c0089

Please sign in to comment.