]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1933: completion: complete_match() is not useful v9.1.1933
authorGirish Palya <girishji@gmail.com>
Thu, 27 Nov 2025 21:19:54 +0000 (21:19 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 27 Nov 2025 21:28:05 +0000 (21:28 +0000)
commitcbcbff871224115c45bbd14582749a487c6fad30
treea3afb4ab711fce233cca0a198dfb9edc1399e810
parentc53150174859c34e96a65c7435743614890cd335
patch 9.1.1933: completion: complete_match() is not useful

Problem:  completion: complete_match() Vim script function and
          'isexpand' option are not that useful and confusing
          (after v9.1.1341)
Solution: Remove function and option and clean up code and documentation
          (Girish Palya).

complete_match() and 'isexpand' add no real functionality to Vim. They
duplicate what `strridx()` already does, yet pretend to be part of the
completion system. They have nothing to do with the completion mechanism.

* `f_complete_match()` in `insexpand.c` does not call any completion code.
   It’s just a `STRNCMP()` wrapper with fluff logic.
* `'isexpand'` exists only as a proxy argument to that function.
   It does nothing on its own and amounts to misuse of a new option.

The following Vim script function can be used to implement the same
functionality:

```vim
  func CompleteMatch(triggers, sep=',')
    let line = getline('.')->strpart(0, col('.') - 1)
    let result = []
    for trig in split(a:triggers, a:sep)
      let idx = strridx(line, trig)
      if l:idx >= 0
        call add(result, [idx + 1, trig])
      endif
    endfor
    return result
  endfunc
```

related: #16716
fixes: #18563
closes: #18790

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
22 files changed:
runtime/doc/builtin.txt
runtime/doc/intro.txt
runtime/doc/options.txt
runtime/doc/tags
runtime/doc/usr_41.txt
runtime/doc/version9.txt
runtime/optwin.vim
runtime/syntax/vim.vim
src/buffer.c
src/evalfunc.c
src/insexpand.c
src/option.c
src/option.h
src/optiondefs.h
src/optionstr.c
src/po/vim.pot
src/proto/insexpand.pro
src/proto/optionstr.pro
src/structs.h
src/testdir/test_ins_complete.vim
src/testdir/util/gen_opt_test.vim
src/version.c