From e80e8a0980aae1f5142d53acfd26b62dd4cbf2ba Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 2 Dec 2024 15:11:38 +0100 Subject: [PATCH] fix(extmark): builtin completion can still affect nearby extmarks #31387 Problem: Built-in completion can still affect nearby extmarks. #31384 Solution: Restore extmarks when completion leader changes. (cherry picked from commit c7ec010ade0832e43c7a319ea69fae642771479d) --- src/nvim/insexpand.c | 1 + test/functional/editor/completion_spec.lua | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 4ba82e6295..274184f833 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1735,6 +1735,7 @@ static void ins_compl_new_leader(void) ins_compl_del_pum(); ins_compl_delete(); ins_bytes(compl_leader + get_compl_len()); + restore_orig_extmarks(); compl_used_match = false; if (compl_started) { diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 4dc18b10ba..facdc94818 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1188,5 +1188,15 @@ describe('completion', function() aaaaa | {5:-- INSERT --} | ]]) + -- Also when completion leader is changed #31384 + feed('hia') + screen:expect({ + grid = [[ + {9:aa}a^aa | + {4:aaaa } | + {4:aaaaa } | + {5:-- Keyword completion (^N^P) }{19:Back at original} | + ]], + }) end) end)