0
0
mirror of https://github.com/vim/vim.git synced 2025-11-15 23:14:06 -05:00

patch 9.1.1797: completion: autocompletion can be improved

Problem:  completion: autocompletion can be improved
Solution: Add support for "longest" and "preinsert" in 'autocomplete';
          add preinserted() (Girish Palya)

* Add support for "longest" in 'completeopt' when 'autocomplete'
  is enabled. (Note: the cursor position does not change automatically
  when 'autocomplete' is enabled.)
* Add support for "preinsert" when 'autocomplete' is enabled. Ensure
  "preinsert" works the same with and without 'autocomplete'
* introduce the preinserted() Vim script function, useful for defining
  custom key mappings.

fixes: #18314
closes: #18387

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya
2025-09-26 17:29:38 +00:00
committed by Christian Brabandt
parent 3fc1f2a00e
commit c05335082a
13 changed files with 336 additions and 114 deletions

View File

@@ -693,11 +693,12 @@ edit(
&& stop_arrow() == OK)
{
ins_compl_delete();
if (ins_compl_has_preinsert()
&& ins_compl_autocomplete_enabled())
(void)ins_compl_insert(FALSE, TRUE);
else
(void)ins_compl_insert(FALSE, FALSE);
ins_compl_insert(FALSE, !ins_compl_has_preinsert());
if (ins_compl_preinsert_longest())
{
ins_compl_init_get_longest();
continue;
}
}
// Delete preinserted text when typing special chars
else if (IS_WHITE_NL_OR_NUL(c) && ins_compl_preinsert_effect())