diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 820647df97..a1cebb407e 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1805,6 +1805,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 030181764d..da4d7a6640 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1302,5 +1302,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)