Files
neovim/runtime/doc
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-06-02 22:59:58 +08:00
2023-04-23 15:22:55 +02:00
2023-05-13 21:33:22 +02:00
2023-04-17 15:46:24 +08:00
2023-04-23 15:22:55 +02:00
2023-05-13 21:33:22 +02:00
2023-04-04 19:07:33 +02:00
2023-05-13 21:33:22 +02:00
2023-04-23 15:22:55 +02:00
2021-09-10 08:48:27 +02:00
2023-05-13 21:33:22 +02:00
2023-01-01 15:05:13 +01:00
2023-04-23 15:22:55 +02:00
2023-05-13 21:33:22 +02:00
2023-05-15 09:38:32 +02:00
2023-05-13 21:33:22 +02:00
2023-04-13 12:15:30 +02:00
2023-05-13 21:33:22 +02:00
2023-05-13 21:33:22 +02:00
2023-05-13 21:33:22 +02:00
2023-06-02 22:59:58 +08:00
2023-06-02 22:59:58 +08:00
2023-05-15 09:38:32 +02:00
2023-01-01 15:05:13 +01:00
2022-10-14 08:01:13 -07:00
2023-02-22 00:07:26 +08:00
2022-12-11 18:41:26 -08:00
2018-10-29 09:55:07 +01:00
2023-05-15 09:38:32 +02:00
2018-10-29 09:55:07 +01:00
2023-05-13 21:33:22 +02:00
2015-08-15 15:25:30 -03:00
2023-04-23 15:22:55 +02:00
2023-06-02 22:59:58 +08:00
2023-05-13 21:33:22 +02:00
2023-04-23 15:22:55 +02:00
2023-02-22 00:07:26 +08:00
2023-01-01 15:05:13 +01:00
2023-05-13 21:33:22 +02:00
2023-05-13 21:33:22 +02:00
2023-04-04 19:07:33 +02:00
2023-04-04 19:07:33 +02:00
2023-05-13 21:33:22 +02:00
2022-09-26 17:43:23 +08:00
2023-02-20 15:12:59 +08:00
2023-05-15 09:38:32 +02:00
2023-01-01 15:05:13 +01:00
2023-05-13 21:33:22 +02:00
2022-07-26 11:26:23 +02:00
2023-05-15 09:38:32 +02:00
2023-04-23 15:22:55 +02:00
2023-04-11 19:10:36 +02:00
2023-01-03 10:07:43 +00:00
2023-04-13 12:15:30 +02:00
2021-05-01 22:29:02 -04:00
2021-05-02 12:53:49 -04:00
2021-05-01 22:29:03 -04:00
2021-04-27 09:21:33 -04:00
2018-10-29 10:01:44 +01:00
2021-04-29 09:27:19 -04:00
2018-10-29 10:01:44 +01:00
2021-04-29 20:42:16 -04:00
2019-03-26 19:55:33 +01:00
2021-04-27 09:21:34 -04:00
2023-01-03 10:07:43 +00:00
2023-01-03 10:07:43 +00:00
2023-04-13 12:15:30 +02:00
2023-05-13 21:33:22 +02:00
2023-02-22 00:07:26 +08:00