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 57521ce
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 @@ -28,6 +26,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

defp changed_line(text_edits) do
lines =
text_edits
Expand Down

0 comments on commit 57521ce

Please sign in to comment.