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

@ -453,6 +453,7 @@ popup_setoptions({id}, {options})
popup_settext({id}, {text}) none set the text of popup window {id}
popup_show({id}) Number unhide popup window {id}
pow({x}, {y}) Float {x} to the power of {y}
preinserted() Number whether text is inserted after cursor
prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
printf({fmt}, {expr1}...) String format text
prompt_getprompt({buf}) String get prompt text
@ -8033,6 +8034,15 @@ pow({x}, {y}) *pow()*
Return type: |Number|
preinserted() *preinserted()*
Returns non-zero if text has been inserted after the cursor
because "preinsert" is present in 'completeopt', or if
"longest" is present in 'completeopt' while 'autocomplete'
is enabled. Otherwise returns zero.
Return type: |Number|
prevnonblank({lnum}) *prevnonblank()*
Return the line number of the first line at or above {lnum}
that is not blank. Example: >