Commit Graph

20569 Commits

Author SHA1 Message Date
zeertzjq
d214c24129 vim-patch:9.2.0538: Cannot keep leading whitespace in %{} statusline expr (#40007)
Problem:  A leading space in the result of a %{} item is sometimes
          stripped, and an all-digit result is converted to a number.
Solution: Add %0{} atom which inserts the expression result verbatim
          (glepnir)

fixes:  vim/vim#3898
closes: vim/vim#20315

e8d7a40b98

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-26 01:04:24 +00:00
zeertzjq
13def2fa3a vim-patch:9.2.0533: '[ mark moved to end of inserted text after CTRL-R CTRL-P paste
Problem:  After CTRL-R CTRL-P (or CTRL-R CTRL-O) pastes a register
          into Insert mode, a follow-up edit such as backspace makes
          stop_arrow() rewrite Insstart with the post-paste cursor
          position.  As a result the '[ mark points at the end of the
          inserted text instead of its start  (agguser, after 9.2.0384)
Solution: In stop_arrow(), only pull Insstart back when the cursor
          moved above the previous Insstart, so a line-start backspace
          can still save the joined range (vim/vim#20031) without disturbing
          the start position for inserts that advance the cursor
          (Hirohito Higashi).

related: vim/vim#20031
fixes:   vim/vim#20130
closes:  vim/vim#20322

bc7805323f

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 07:28:38 +08:00
bfredl
2d192f3e6d Merge pull request #39920 from bfredl/luastring
fix(lua): use even safer and even better error() message conversion
2026-05-25 16:35:40 +02:00
Michał Dominiak
70792aa6e4 fix(marks): read from the correct variable in conceal_lines mark collection (#39991)
Problem:  Not using current mark for namespace check during iteration for conceal_line marks.
Solution: Use the appropriate mark variable for namespace check.
2026-05-25 11:19:26 +02:00
bfredl
24e23de721 fix(lua): use even safer and even better error() message conversion
problem:
this crashes neovim:

ondska = setmetatable({}, {__tostring = error})
error(ondska)

solution:

make it not crash neovim
2026-05-25 11:06:02 +02:00
zeertzjq
01a21ec5b6 vim-patch:9.2.0525: spell: memory leak in spell_read_dic()
Problem:  spell: memory leak in spell_read_dic() (after 9.2.0524).
Solution: Free "pc" before breaking out of the loop (zeertzjq).

closes: vim/vim#20309

6c8e125395
2026-05-24 18:03:23 +08:00
zeertzjq
1bf38c302d vim-patch:9.2.0524: spell: buffer overflow with many affix or compound flags
Problem:  spell: a word in a .dic file with many postponed prefix or
          compound flags overflows the fixed-size store_afflist[MAXWLEN]
          buffer in get_pfxlist() and get_compflags().
Solution: Add bounds checks (Yasuhiro Matsumoto).

closes: vim/vim#20286

9a920e8254

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-05-24 18:02:03 +08:00
zeertzjq
1a064abb0a vim-patch:9.2.0517: quickfix: can set quickfixtextfunc in restricted/sandbox mode (#39970)
Problem:  quickfix: can set quickfixtextfunc in restricted/sandbox mode
          (tacdm)
Solution: Disallow setting the quickfixtextfunc option from a sandbox
          and restricted mode (Yegappan Lakshmanan).

closes: vim/vim#20305

cb8510d470


Co-Authored-by: tacdm

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2026-05-24 08:49:02 +08:00
zeertzjq
daf2506a6d vim-patch:ecba601: runtime(doc): fix a few small problems (#39969)
closes: vim/vim#20287

ecba601e3f
2026-05-24 00:10:36 +00:00
zeertzjq
b6b2b12494 vim-patch:9.2.0515: virtualedit=insert doesn't work during change operation (#39968)
Problem:  virtualedit=insert doesn't work during change operation
          (after 6.1.014).
Solution: Make virtual_op only affect virtualedit=block (zeertzjq).

related: neovim/neovim#35391
closes:  vim/vim#20298

3d0a6073e5
2026-05-23 23:59:08 +00:00
zeertzjq
c8dbb04da9 vim-patch:9.2.0510: setline() mapping may trigger autoindent (#39961)
Problem:  setline() insert mode mapping may trigger autoindent,
          corrupting the newly inserted line content (Evgeni Chasnovski)
Solution: Only strip autoindent whitespace when the rest of the line is
          all whitespace (glepnir).

fixes:  vim/vim#19363
closes: vim/vim#20290

e3dedac77b

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-23 08:57:36 +08:00
zeertzjq
7a1bad27ca vim-patch:9.2.0513: [security]: memory safety issues in spellfile.c (#39960)
Problem:  [security]: memory safety issues in spellfile.c
          (tacdm)
Solution: Add recursion limit to read_tree_node(), add length limit
          check in tree_count_words(), use alloc_clear() in
          spell_read_tree().

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-3h95-3962-mmvf

25e4e46c58

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 00:51:47 +00:00
zeertzjq
f53d9ac90b vim-patch:c7645fc: runtime(doc): add a few references to mouse behaviour (#39959)
fixes: vim/vim#20281

c7645fcda5

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-23 07:47:49 +08:00
Luuk van Baal
b58ce1ab79 fix(statusline): no cmdline ruler for autocommand window
Problem:  Cmdline ruler may be drawn for autocommand window.
Solution: Check that the current window is not an autocommand window
          when deciding whether to draw the ruler.
2026-05-22 17:54:24 +02:00
zeertzjq
dee602e659 vim-patch:9.2.0508: completion: cannot complete user cmd :K with 'ignorecase' (#39944)
Problem:  completion: cannot complete user cmd :K with 'ignorecase'
          (rendcrx)
Solution: Skip the short-circuit when 'ignorecase' is set
          (Yasuhiro Matsumoto)

The set_cmd_index() short-circuit for the :k command treats ":k<X>" as
":k {X}" (mark argument), which makes ":kz<Tab>" never reach the
command-name expansion path. With 'ignorecase' the same prefix on other
letters (":gz<Tab>") completes a user command like :Gz, so the result is
inconsistent. Skip the short-circuit when 'ignorecase' is set; default
behaviour is preserved so the existing :k tests still pass.

fixes:  vim/vim#20241
closes: vim/vim#20275

b54e57ee54

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-05-22 08:07:55 +08:00
glepnir
7662001c48 fix(float): simplify :bufdelete focus retry #39928
Problem:
Followup to #39858. close_windows returned a holder window just so
do_buffer_ext could retry there, but the non-float branch was dead code
and close_windows was called twice.

Solution:
Check one_window directly in do_buffer_ext, drop the holder, make
close_windows void again.

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2026-05-21 10:38:04 -04:00
glepnir
26df751add fix(float): :bufdelete in floatwin may change focus #39858
Problem:
(Followup to 54f22a8f01c0feb27a531b52aedf5cdbd5e51b24.)
Deleting another buffer from a floatwin could move focus into the holder
window and fire BufEnter for the buffer being deleted.

Solution:
Use switch_win_noblock() instead of buf_jump_open_win() before
recursing into do_buffer_ext().
2026-05-21 05:06:50 -04:00
Kyle
7337e02563 refactor(docs): generate tui.txt $NVIM_TERMDEFS keys #39836
Problem:
Potential documentation drift in `tui.txt` if fields for
`$NVIM_TERMDEFS` change.

Solution:
Generate docs for `tui.txt`. Add `brief_xform` to `gen_vimdoc.lua` to
allow transforming briefs during generation.
2026-05-21 04:39:45 -04:00
zeertzjq
a952575c3b vim-patch:9.2.0506: home_replace() function can be improved (#39925)
Problem:  home_replace() function can be improved
Solution: Refactor home_replace() to return the length of the string
          (John Marriott).

In addition:
- in function set_b0_fname() move ulen into the block where it is used.
- In function findswapname() rework logic around displaying "swap file
  already exists" dialogue so that literal message text is set once.

closes: vim/vim#20249

a0931a90ee

Co-authored-by: John Marriott <basilisk@internode.on.net>
2026-05-21 09:35:27 +08:00
Justin M. Keyes
9f0ecad6d9 fix(api): fail fast if has_lua_imp retval looks wrong #39866 2026-05-20 11:52:22 -04:00
luukvbaal
53da0c5060 fix(messages): avoid recursive rtp build due to msg_show #39888
Problem:  If there are pending messages when starting to build the
          runtime search path, a msg_show callback may invoke
          runtime_search_path_validate() recursively.
Solution: Avoid msg_show callback by ensuring messages are flushed.
2026-05-20 08:13:41 -04:00
Matei Stroia
526ae1cc1b fix(fold): virtual lines duplicate foldopen (#39891)
Problem:
Virtual lines above a line where a fold starts show `foldopen` in
`foldcolumn`.

Solution:
Check if the line below the virtual one is inside a fold that starts
higher up or if it's the start of a fold. In the latter case, don't show
anything in `foldcolumn` for the virtual line.

refactor: lint
2026-05-20 19:56:39 +08:00
bfredl
2e82e0bcf6 Merge pull request #39887 from bfredl/o_dod_suss
fix(warnings): annotate or ignore all uses of printf formatting
2026-05-20 12:55:30 +02:00
Justin M. Keyes
f1fad32e2e docs: misc, custom text-object #39877
text-object-define is a pattern I found in tpope's plugins (e.g.
https://github.com/tpope/vim-jdaddy) which shows an elegant way to
define a text-object. (Any mistakes in the example are my fault.)
2026-05-20 05:21:27 -04:00
Barrett Ruth
5181984db9 fix(api): nvim_exec_autocmds({buf=x}) runs in buffer context #39061
Problem: `nvim_exec_autocmds({ buf = ... })` matches the target buffer, but callbacks and modelines run with the caller buffer current rather than the target buffer.

Solution: Execute the buffered path in prepared target-buffer context and restore the caller afterward.
2026-05-20 03:48:55 -04:00
bfredl
3d391cf84d fix(warnings): annotate or ignore all uses of printf formatting
This fixes all clang 22 warnings of the form: "warning: diagnostic behavior
may be improved by adding the 'format(printf, 3, 4)' attribute to the
declaration of 'some_function'"

dialog_msg() was essentially a NULL-handling wrapper. but some callsites
already use their own NULL handling or NULL:s are impossible as the
value has already been assumed non-NULL. Non-locally assuming
a buffer size is also a code smell, especially if we can
just use "sizeof buff" without a wrapper.

append_redir() is... whatever it is.
2026-05-19 19:42:58 +02:00
Nick Krichevsky
24f7182390 fix(mouse): mouse=n should not adjust visual selection
Problem:

When mouse=n is set
  - Dragging the mouse enters visual mode, and then stops listening for
    mouse events.
  - Double/Triple/Quad clicking performs selections.
  - Clicking in visual mode moves the cursor (though not through the TUI).

Solution:

Explicitly gate mouse actions that affect visual mode with a check for
MOUSE_VISUAL. This matches the behavior described in :help mouse.

> If enabled for "v" (Visual mode) then double-click selects word-wise,
> triple-click makes it line-wise, and quadruple-click makes it
> rectangular block-wise.
2026-05-19 11:45:56 +02:00
Justin M. Keyes
16d17c50bb refactor: simplify aucmd_restbuf usage #39879
Problem:
`aucmd_restbuf` must be guarded in case `aucmd_prepbuf` wasn't called.

Solution:
Update `aucmd_restbuf` to be a no-op if `aucmd_prepbuf` wasn't called.
This requires `aco` to be zero-initialized.
2026-05-19 05:09:23 -04:00
Barrett Ruth
353d2a4e4a feat(normal): lines textobject "il", "al" #39845
`al` to select the whole buffer linewise.
`il` to select the current line without surrounding whitespace.
2026-05-19 05:08:23 -04:00
glepnir
450ba41436 fix(api): adjust Visual position after nvim_buf_set_text #30690
Problem:
Visual selection could end up in the wrong place after
nvim_buf_set_text or nvim_buf_set_lines. In some delete cases,
Visual.lnum was already clamped before the line shift happened, so the
adjustment got skipped.

Solution:
Split fix_cursor_cols into reusable fix_pos_col logic and reuse it
for Visual updates. Also adjust Visual.lnum before changed_lines so
the shift uses the original position before final clamping.
2026-05-18 13:08:26 -04:00
Manoj Panda
4791444953 refactor: remove unused MAP_DECLS specializations #39865
Problem:
Various "unused function" warnings when building `map_defs.h`.
https://github.com/neovim/neovim/issues/26452

Solution:
Removed unused `MAP_DECLS(T, U)` specializations, their generated symbols, and
2 obsolete constants.
2026-05-18 11:25:03 -04:00
Justin M. Keyes
b20fa21ac5 Merge #39832 from justinmk/doc2
docs: misc, remove legacy/textobjects_spec.lua
2026-05-18 09:25:05 -04:00
bfredl
e932d6ff17 fix(api): regressions with lua return values #39837
fixes #39834
fixes #39833
fixes #39851
2026-05-18 09:05:49 -04:00
zeertzjq
7b46848f14 vim-patch:9.2.0494: User commands cannot handle single args with spaces (#39854)
Problem:  User commands cannot handle single args with spaces
Solution: Add the -nargs=_ attribute (Maxim Kim)

-nargs=_ allow user commands to have a single argument with spaces.

For example given the following Test command and TestComplete function:

```
vim9script
def TestComplete(A: string, _: string, _: number): list<string>
    var all = ["qqqq", "aaaa", "qq aa"]
    return all->matchfuzzy(A)
enddef
command! -nargs=_ -complete=customlist,TestComplete Test echo <q-args>
```

`:Test q a<tab>` should successfully complete `qq aa`

fixes:  vim/vim#20102
closes: vim/vim#20189

f0e874a129

Co-authored-by: Maxim Kim <habamax@gmail.com>
2026-05-18 17:44:26 +08:00
Justin M. Keyes
82cc02d19f docs: misc, $NVIM_TERMDEFS 2026-05-18 11:20:18 +02:00
Kyle
84d5c5f4bf feat(tui): $NVIM_TERMDEFS can override builtin terminfo #39555
Problem:
- Windows users can't use terminfo to configure their terminal
  capabilities. #37274
- Terminfo definitions sometimes get out of date or are simply
  inaccurate.
- Eventually, we may want to drop terminfo, relying primarily on
  built-in definitions. Users will still need some flexibility.

Solution:
Support $NVIM_TERMDEFS environment variable, which is JSON data that
defines "terminfo" definitions that override our builtin terminfo.
2026-05-17 13:02:46 -04:00
Puneet Dixit
fff9897ce3 fix(startup): emitting useless OptionSet #39830
Problem:
During startup, we manually trigger a useless and misleading `OptionSet`
event, which doesn't set `v:option_*` values (this is a limitation of
`nvim_exec_autocmds`).
ad4bc2d90c/runtime/lua/vim/_core/defaults.lua (L939).

Solution:
The `nvim_exec_autocmds('OptionSet',…)` call does not serve any purpose
since 5cbb9d613b, so just drop it.
2026-05-17 12:18:24 -04:00
Justin M. Keyes
846b8b2420 refactor: group nvim_buf_call, nvim_win_call tests #39828 2026-05-17 11:20:54 -04:00
Barrett Ruth
38c18ad3a8 fix(vimscript): normalize multi-slash heads in fnamemodify() #39805
Problem: `fnamemodify(..., ':h')` mishandles POSIX leading slash runs longer than `//`.

Solution: Collapse those slash runs to `/` before computing the head.
2026-05-17 10:54:59 -04:00
bfredl
0aa7d2f4d5 feat(api): nvim_buf_call, win_call can has multiple return values #39801
from the "because we can and it is not much code" department. (diffcount
excluding tests is actually negative)

fixes https://github.com/neovim/neovim/issues/39636#issuecomment-4397141270
2026-05-17 10:25:22 -04:00
Justin M. Keyes
e572c9c80a feat(api): tab-local option scope #39811
Problem:
2d795face6 added support for tab-local options ('cmdheight')
to `nvim_get_option_value`, but not to:

    nvim_get_option_info2()
    nvim_set_option_value(…, { tab = … })
    gettabwinvar()

Solution:
- Update `options.lua` to model tab-local options. Introduce `kOptScopeTab`.
- Handle tab scope in the options layer so it works for all options APIs.

Note:
- No change to `gettabvar()`. Not sure if needed/wanted.

fix https://github.com/neovim/neovim/issues/31140
2026-05-17 10:24:46 -04:00
Justin M. Keyes
c55b6128f8 docs: misc #39817 2026-05-17 10:02:12 -04:00
yashlala
7d99104058 feat(events): add TabMoved autocommand event #24137
Problem:
No way to handle a "tab moved" event.
Use-case: tabline plugins may cache tab labels, and need to know when to
invalidate their cache.

Solution:
Add a `TabMoved` event that triggers whenever tabs are reordered via `:tabmove`
or via mouse click-and-drag.
2026-05-16 13:55:42 -04:00
Guilherme Batalheiro
0b96b3cd52 fix(shada): set correct buffer number for local marks on read #39712
Problem:
After closing and reopening Neovim, ]' and [' fail with E92: Buffer 0
not found for marks restored from ShaDa. Direct jumps like 'a work
because mark_get_local() rewrites fnum before returning, but ]' uses
getnextmark() which does not, leaving fnum = 0.

Solution:
Set .fnum = buf->b_fnum when restoring local marks from ShaDa.
2026-05-16 13:53:34 -04:00
glepnir
54f22a8f01 fix(excmd): :bufdelete may fail from floating window #39800
Problem: with a float focused and the target buf only shown in the
last non-float window, do_buffer_ext goes down the buf != curbuf
path. close_windows can't touch the last non-float, b_nwindows stays
> 0, close_buffer is skipped, returns OK silently.

Solution: if a non-float still holds buf after close_windows, jump
into it and recurse. Then buf == curbuf and the existing replacement
path takes over.
2026-05-16 12:25:18 -04:00
Justin M. Keyes
5ba0d28634 refactor(api): tab-local nvim_get_option_value #39810 2026-05-16 11:37:37 -04:00
Tomas Slusny
a0637e0c4e feat(prompt): support 'scrollback' option in prompt-buffers #39793
Problem:
There is a lot of overlap between terminal and prompt buffer, but no
easy way to limit the number of lines kept above the prompt to prevent
performance and other issues. This is desirable for both example
use cases in current documentation, chat UI and repl/shell plugins.

Solution:
Use existing 'scrollback' option to limit prompt-buffer lines
as well.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-05-16 10:14:18 -04:00
EliWiegman
2d795face6 fix(api): nvim_get_option_value tab-local 'cmdheight' #39259
Problem:
API clients cannot query the tab-local value of 'cmdheight'.

Solution:
Allow nvim_get_option_value() to accept { tab = <tab-ID> } for 'cmdheight'.
2026-05-16 09:31:05 -04:00
zeertzjq
b92ca58d69 vim-patch:9.2.0490: matchfuzzy() can crash on long multi-word patterns (#39809)
Problem:  matchfuzzy() can crash on long multi-word patterns.
Solution: Clamp pat_chars to maxMatches and stop before calling
          match_positions() when the buffer is full (glepnir).

closes: vim/vim#20209

88b00d1c57

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-16 18:28:42 +08:00
Olivia Kinnear
b62c1049c0 feat(pack): :packupdate, :packdel commands #39693
Define `:packupdate` and `:packdel` as separate commands instead of a
unified `:pack {subcommand}` because the semantics between the two
commands vary differently enough that it doesn't make sense to combine
them. Additionally, `:pack! update/del` looks bad.
2026-05-16 05:15:05 -04:00