Skip to content

Commit

Permalink
Multiple edits could cause invalid text edits
Browse files Browse the repository at this point in the history
This is not really a proper fix since it will make text editing
less efficient, but finding the root cause is tricky.

A follow up chagne could be made to fix the root cause.

Fixes #1427.
  • Loading branch information
plux committed Jan 9, 2024
1 parent 9696858 commit c05fc92
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apps/els_core/src/els_text.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,13 @@ last_token(Text) ->
apply_edits(Text, []) ->
Text;
apply_edits(Text, Edits) when is_binary(Text) ->
Lines = lists:foldl(
lists:foldl(
fun(Edit, Acc) ->
apply_edit(Acc, 0, Edit)
lines_to_bin(apply_edit(bin_to_lines(Acc), 0, Edit))
end,
bin_to_lines(Text),
Text,
Edits
),
lines_to_bin(Lines).
).

-spec apply_edit(lines(), line_num(), edit()) -> lines().
apply_edit([], L, {#{from := {FromL, _}}, _} = Edit) when L < FromL ->
Expand Down

0 comments on commit c05fc92

Please sign in to comment.