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
2022-10-18 07:18:44 -07:00
2023-06-04 09:09:22 +08:00
2023-06-03 12:06:00 +02:00
2023-04-23 15:22:55 +02:00
2022-12-02 16:05:00 +01:00
2023-05-13 21:33:22 +02:00
2019-05-09 20:27:11 -04:00
2023-06-03 12:06:00 +02:00
2022-12-02 16:05:00 +01:00
2023-02-22 16:23:49 +01:00
2023-04-17 12:53:34 +01: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-05-11 15:43:02 +08:00
2023-04-23 15:22:55 +02:00
2022-10-14 08:01:13 -07:00
2021-09-10 08:48:27 +02:00
2023-05-13 21:33:22 +02:00
2022-10-29 17:41:22 +02:00
2023-01-01 15:05:13 +01:00
2023-04-23 15:22:55 +02:00
2023-02-28 15:14:03 +01:00
2023-06-03 12:06:00 +02:00
2023-05-13 21:33:22 +02:00
2023-04-29 09:20:52 +08:00
2023-05-15 09:38:32 +02:00
2023-04-29 09:20:52 +08: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-05-30 20:56:29 +02:00
2023-06-02 22:59:58 +08:00
2023-06-03 12:06:00 +02:00
2023-06-02 22:59:58 +08:00
2023-06-03 12:06:00 +02:00
2023-05-15 09:38:32 +02:00
2023-01-01 15:05:13 +01:00
2022-12-05 21:09:31 +08:00
2022-10-14 08:01:13 -07:00
2023-02-22 00:07:26 +08:00
2023-04-07 16:11:02 +02:00
2023-06-04 16:45:01 -07:00
2023-03-21 05:43:40 -07:00
2022-12-11 18:41:26 -08:00
2023-05-24 10:04:49 +02:00
2023-02-21 23:50:29 +08:00
2018-10-29 09:55:07 +01:00
2023-05-05 18:15:44 +02:00
2022-10-06 06:16:00 -07:00
2023-05-15 09:38:32 +02:00
2018-10-29 09:55:07 +01:00
2023-01-01 15:05:13 +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-05-02 13:11:26 +02:00
2023-04-23 15:22:55 +02:00
2023-02-22 00:07:26 +08:00
2023-02-21 23:50:29 +08:00
2023-06-02 21:00:55 +08:00
2023-01-01 15:05:13 +01:00
2022-10-14 08:01:13 -07:00
2022-07-06 19:34:24 +08: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
2022-12-02 16:05:00 +01:00
2023-05-15 09:38:32 +02:00
2023-01-01 15:05:13 +01:00
2023-05-15 14:13:42 +02:00
2023-02-21 23:50:29 +08:00
2023-05-13 21:33:22 +02:00
2022-07-26 11:26:23 +02:00
2023-04-16 15:04:41 +08:00
2023-05-15 09:38:32 +02:00
2023-02-21 23:50:29 +08:00
2023-04-23 15:22:55 +02:00
2022-02-24 18:13:44 +08:00
2023-04-11 19:10:36 +02:00
2023-01-03 10:07:43 +00:00
2022-02-24 18:13:44 +08:00
2023-01-01 15:05:21 +01:00
2023-04-13 12:15:30 +02:00
2023-01-01 15:05:21 +01:00
2021-05-01 22:29:02 -04:00
2021-05-02 12:53:49 -04:00
2023-01-01 15:05:21 +01:00
2023-01-01 15:05:21 +01:00
2023-02-21 23:50:29 +08:00
2021-05-01 22:29:03 -04:00
2021-04-27 09:21:33 -04:00
2023-01-01 15:05:21 +01: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
2023-01-01 15:05:21 +01:00
2023-01-01 15:05:21 +01:00
2021-04-29 20:42:16 -04:00
2023-01-01 15:05:21 +01:00
2023-01-01 15:05:21 +01:00
2023-05-04 17:40:29 +08:00
2023-01-01 15:05:21 +01:00
2019-03-26 19:55:33 +01:00
2021-04-27 09:21:34 -04:00
2022-10-14 08:01:13 -07:00
2023-01-03 10:07:43 +00:00
2023-04-02 15:24:55 +02: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