Files
neovim/runtime
Folke Lemaitre 5282d3299c fix(lsp): restore marks after apply_text_edits() #14630
PROBLEM:
Whenever any text edits are applied to the buffer, the `marks` part of those
lines will be lost. This is mostly problematic for code formatters that format
the whole buffer like `prettier`, `luafmt`, ...

When doing atomic changes inside a vim doc, vim keeps track of those changes and
can update the positions of marks accordingly, but in this case we have a whole
doc that changed. There's no simple way to update the positions of all marks
from the previous document state to the new document state.

SOLUTION:
* save marks right before `nvim_buf_set_lines` is called inside `apply_text_edits`
* check if any marks were lost after doing `nvim_buf_set_lines`
* restore those marks to the previous positions

TEST CASE:
* have a formatter enabled
* open any file
* create a couple of marks
* indent the whole file to the right
* save the file
Before this change: all marks will be removed.
After this change: they will be preserved.

Fixes #14307
2023-06-04 16:45:01 -07:00
..
2023-05-15 09:38:32 +02:00
2023-04-23 15:22:55 +02:00
2022-12-08 16:33:38 +01:00
2023-05-15 09:38:32 +02:00
2021-09-13 16:33:41 +02:00
2021-05-01 22:29:03 -04:00
2023-05-15 09:38:32 +02:00
2023-05-15 09:38:32 +02:00
2022-08-20 10:04:55 +02:00
2021-04-27 09:21:32 -04:00
2023-05-15 09:38:32 +02:00
2023-04-13 12:15:30 +02:00
2023-04-07 13:26:29 +02:00
2022-10-17 08:19:48 +02:00