Commit Graph

20527 Commits

Author SHA1 Message Date
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
zeertzjq
1813e1c089 vim-patch:9.2.0486: out-of-bound read when recovering swap files (#39807)
Problem:  out-of-bound read when recovering corrupted swap files
          (Rahul Hoysala)
Solution: Validate the db_txt_start field when recovering a swap
          file.

Supported by AI

de7a5b5425

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-16 08:07:22 +08:00
Justin M. Keyes
4f27b585e9 docs: dev, lsp, indent-guides #39756
- document "indent guides" https://github.com/neovim/neovim/issues/39726
- document guidance for "subcommands" https://github.com/neovim/neovim/issues/32263#issuecomment-4436002808

Co-authored-by: glepnir <glephunter@gmail.com>
Co-authored-by: Noa Levi <275430404+lphuc2250gma@users.noreply.github.com>
2026-05-14 13:13:30 -04:00
Michele Campeotto
6780e78b09 feat(highlights): new Dimmed hl group for de-emphasized text #39505
Problem:
Many color schemes assume the Comment hl group is dim text and use it
for secondary text, decorations, or parts of UI. This is true for many
color schemes but not all.

Solution:
Introducing a new highlight group with a more specific meaning, similar
to Underlined or Ignore.

The new group links to Comment by default so the behavior is unchanged
for color schemes that don't define it.
2026-05-13 15:54:34 -04:00
github-actions[bot]
d3f3d75451 docs: update version.c #39663
vim-patch:fbec828c7 CI: Bump the github-actions group across 1 directory with 2 updates
vim-patch:852f4f43c runtime(doc): Fix manpage typo in description of '--ttyfail'
vim-patch:9.2.0472: popup: column jitters when scrolled outside viewport
vim-patch:9.2.0474: MS-Windows: hard to tell which Visual Studio version was selected with MSVC
vim-patch:78302b7b4 translation(it): Update Italian manpage
vim-patch:9.2.0477: popup: leftover content after popup_free under layout change
vim-patch:9.2.0478: channel: redundant str/length assignments in channel_part_info()

vim-patch:9.2.0460: did_set_shellpipe_redir() in wrong file
vim-patch:9.0.2153: no support to build on OpenVMS
vim-patch:9.2.0290: Amiga: no support for AmigaOS 3.x
2026-05-13 15:44:19 -04:00
Lewis Russell
9432e6c1e2 test: run Lua harness with nvim -l
Problem:
The Lua test harness still ran through standalone -ll mode, so tests
depended on the low-level Lua path instead of the regular Nvim Lua
environment. That also meant os.exit() coverage had to carry an ASAN
workaround because Lua's raw process exit skipped Nvim teardown and let
LeakSanitizer interfere with the observed exit code.

Solution:
Run the harness and related fixtures with nvim -l. Patch os.exit() in
the main Lua state to exit through getout(), so scripts observe normal
Nvim shutdown while standalone -ll remains available for generator-style
scripts. As a consequence, the startup test can assert os.exit() without
disabling leak detection.

AI-assisted: Codex
2026-05-13 13:14:07 +01:00
luukvbaal
706cbbff33 fix(grid): keep grid sizes updated during redraw #39757
Problem:  Assert tripped when window is resized during update_screen().
Solution: Re-allocate grid when resizing happens during update_screen().
2026-05-13 07:46:30 -04:00
zeertzjq
89b5a1a181 fix(ui_client): fix memory leak (#39770) 2026-05-13 10:25:43 +08:00
zeertzjq
3b3d3076f7 vim-patch:9.2.0476: pattern completion leaks memory on alloc failures (#39767)
Problem:  copy_substring_from_pos() leaked on ga_grow() failures,
          expand_pattern_in_buf() leaked "match" on ga_grow() failure,
          fuzzy_match_str_with_pos() ignored ga_grow() failures
Solution: Route failures through cleanup paths, check ga_grow before
          writing to ga_data (glepnir)

closes: vim/vim#20203

38237411e4

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-13 08:56:18 +08:00
zeertzjq
986382069a refactor: make nvim_put() trigger TextPut* with '_' as regname 2026-05-13 06:57:07 +08:00
zeertzjq
58184d3fa3 vim-patch:9.2.0473: Pasting ". register without autocommands breaks TextPut*
Problem:  Pasting ". register without TextPut* autocommands breaks
          subsequent TextPut* autocommands (after 9.2.0470).
Solution: Only decrement add_last_insert if it has been incremented
          (zeertzjq).

closes: vim/vim#20192

a70b7a85af
2026-05-13 06:57:07 +08:00
zeertzjq
871b4b1642 vim-patch:9.2.0470: No way to hook into put commands
Problem:  No way to hook into put commands
          (yochem)
Solution: Introduce TextPutPre and TextPutPost autocommands
          (Foxe Chen).

fixes:  vim/vim#18701
closes: vim/vim#20144

e0781bd5bf

Co-authored-by: Foxe Chen <chen.foxe@gmail.com>
2026-05-13 06:57:07 +08:00
luukvbaal
de67f93aea fix(messages): fast context for for nvim_echo({kind}) callback #39755
Problem:  vim.ui_attach() callback for nvim_echo() call that spoofs an
          internal message kind is executed in fast context.

Solution: Set msg_show callback |api-fast| context dynamically at
          external message callsites, and for internal list_cmd",
          "progress" and "shell*" messages.
2026-05-12 16:28:54 -04:00
Tomas Slusny
a977e1077b fix(prompt): handle multi-element lists in prompt_appendbuf #39550
Problem:
When using prompt_appendbuf with multi-element list,
the first item is concated and rest replace the prompt instead of
inserting the lines before the prompt.

Solution:
Concat first element with replace_buf and insert the rest of the list
with set_buffer_lines.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
2026-05-12 12:00:04 -04:00
li
807f3703c4 refactor(main.c): unused "cwd" variable #39751 2026-05-12 15:45:01 +00:00
bfredl
7673adc952 Merge pull request #38675 from bfredl/errdefer
feat(ui_client): "press ENTER" free nvim crashes
2026-05-12 11:00:26 +02:00
zeertzjq
b51cf60c8d vim-patch:9.2.0471: vimvars di_key initialized at runtime (#39747)
Problem:  evalvars_init() copies each vimvar's name into di_key at
          startup and runtime-checks that the name fits in
          DICTITEM16_KEY_LEN, even though all names are known at
          compile time.
Solution: Embed the name in di_key via the VV_NAME macro so the
          initialization happens at compile time.  Drop the
          runtime length check and the STRCPY loop (John Marriott).

closes: vim/vim#20185

1b65cfbac5

Co-authored-by: John Marriott <basilisk@internode.on.net>
2026-05-11 23:51:42 +00:00
luukvbaal
96fc7c150f fix(api): don't update 'title' when renaming non-curbuf #39743
Problem:  'title' is updated when changing the name of a non-current
          buffer with nvim_buf_set_name().
Solution: Set RedrawingDisabled when renaming the buffer.
2026-05-11 15:54:55 -04:00
luukvbaal
ce9f4f0369 fix(messages): reset redirection message column after :echon #39472
Problem:  Message redirection column for captured output is not reset
          after :echon since (4260f73, e63346df).

Solution: Ensure msg_ext_append is set before the kind with :echon.
2026-05-11 15:47:19 -04:00
bfredl
8275b7b491 Merge pull request #39736 from bfredl/odod
fix(style): some clang-tidy 22 fixes
2026-05-11 16:27:14 +02:00
zeertzjq
41e8201c6c fix(terminal): memory leak when pasting '=' register (#39738)
Problem:  Memory leak when pasting '=' register in terminal.
Solution: Free the register.
2026-05-11 13:07:39 +00:00
bfredl
7e9015fecb fix(style): some clang-tidy 22 fixes
CI currently uses clang-tidy 20, but this affects local builds
and CI is going to be upgraded sooner or later.

Some remaining systematic issues:

- clang-tidy warns agains any atoi() or atol() usage (because of no
  error handling)

- functions which takes (char *fmt, char *only_string_arg) and expect
  fmt to contain exactly one "%s" usage.

- error: initializing non-local variable with non-const expression depending on
  uninitialized non-local variable (cppcoreguidelines-interfaces-global-init)

  This is a much worse problem in C++ (hence C++ core guidelines) where
  initialization is intermingled with arbitrary code execution. I
  "think" in plain C, the linker will either resolve all these
  deterministically or barf an error. But with some restructuring
  we could make all static initialization actually static..
2026-05-11 13:31:10 +02:00
zeertzjq
17e737ed93 vim-patch:partial:9.2.0341: some functions can be run from the sandbox (#39733)
Problem:  some functions can be run from the sandbox
Solution: Block them, so they are not accessible from a modeline
          (q1uf3ng)

closes: vim/vim#19975

fcc4276db3

Co-authored-by: q1uf3ng <q1uf3ng@protone.me>
2026-05-11 10:21:16 +00:00
bfredl
9c42db1181 feat(ui_client): "press ENTER" free nvim crash debugging
This feature might be a little silly and niche, but it is very useful
for _my_ workflow (and open source is about mee)

An issue which is never present on high quality RELEASE builds, but
might occur on Debug builds is that the Nvim server crashes
on some error in your unfinished PR code. If you compile your debug
builds with sanitizers enabled, as you should, the ASAN/UBSAN runtime
will print some useful info about your mistake to stderr or a log file,
such as a stack trace. This can be used to jump to the error in the
code.

This allows the nvim server to install a signal hander in the ui client,
which can load this log file in a good safe version of nvim and parse it
using 'errorformat'

This is inspired by the "press ENTER" free workflow of ui2 and applies
it beyond the lifetime cycle of the nvim instance.

example config:
```lua
    local asan = vim.env.ASAN_OPTIONS
    if asan ~= nil and string.match(asan, "log_path=/tmp/nvim_asan")  then
      local myname = "/tmp/nvim_asan."..vim.uv.getpid()

      local args = {"--embed", "-n", "+set efm=%+A%*[^/]%f:%l:%c", "+silent cfile "..myname, "+silent cfirst", "+silent copen"}

      vim.api.nvim__set_restart_on_crash("nvim", args)
    end
```

and run your debug nvim like so

    ASAN_OPTIONS=handle_abort=1,handle_sigill=1,log_path=/tmp/nvim_asan ./build/bin/nvim
2026-05-11 11:00:03 +02:00
Justin M. Keyes
1f4ad7808e docs: misc, window #39720
- formalize `window-number` similar to `tabpage-number`.
- reference it from docs.
2026-05-10 13:00:52 -04:00
Yi Ming
eb79cf5aee feat(logging): vim.log #38906 2026-05-10 11:03:15 -04:00
zeertzjq
2d5f56c0aa vim-patch:9.2.0461: Corrupted undofile causes use-after-free (#39707)
Problem:  The four pointer-resolution loops in u_read_undo() lack
          an i != j guard, so a header whose uh_next.seq equals
          its own uh_seq resolves uh_next.ptr to itself.  On
          buffer close, u_freeheader() sees uhp->uh_next.ptr !=
          NULL and skips updating b_u_oldhead, so u_blockfree()
          dereferences the freed header on the next iteration.
          The same pattern applies to uh_prev, uh_alt_next and
          uh_alt_prev.  A crafted .un~ file in the same directory
          as a text file can trigger the use-after-free and
          subsequent double-free when the buffer is closed.
          (Daniel Cervera)
Solution: Add an i != j guard to each of the four resolution
          loops, matching the guard already present in the
          duplicate-detection loop above.

closes: vim/vim#20168

Supported by AI

4f610f07b7

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-10 08:06:07 +08:00
zeertzjq
ffe87d91f7 vim-patch:9.2.0458: Crash with invalid shellredir/shellpipe value (#39691)
Problem:  Crash with invalid shellredir/shellpipe value
          (bfredl)
Solution: Validate the option and allow only a single "%s".

fixes:  vim/vim#20157
closes: vim/vim#20159

84ae09dd79

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-09 01:13:19 +00:00
zeertzjq
900975d30d vim-patch:9.2.0455: 'findfunc' only allows extra info for cmdline completion
Problem:  'findfunc' only allows extra info for cmdline completion, not
          for actually finding files (Maxim Kim, after 9.2.0451).
Solution: Handle returning a list of dicts when actually finding files.
          Also fix crash on NULL string (zeertzjq).

fixes:  vim/vim#20163
closes: vim/vim#20164

9694ff58fe
2026-05-09 08:05:56 +08:00
zeertzjq
bf173c3e88 vim-patch:9.2.0451: 'findfunc' can't return extra info for cmdline completion
Problem:  'findfunc' can't return extra info for cmdline completion
          (Maxim Kim).
Solution: Handle 'findfunc' return value in cmdline completion like that
          of "customlist" functions (zeertzjq).

fixes:  vim/vim#20155
closes: vim/vim#20158

58124789aa
2026-05-09 08:05:46 +08:00
phanium
b7d8a41d91 build: strncat warning in buf_write #39684
To make gcc happy
```
src/nvim/bufwrite.c: In function ‘buf_write’:
src/nvim/bufwrite.c:1674:5: warning: ‘strncat’ specified bound depends
on the length of the source argument [-Wstringop-overflow=]
 1674 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |     ^
src/nvim/bufwrite.c:1674:34: note: length computed here
 1674 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |                                  ^
src/nvim/fileio.c: In function ‘filemess’:
src/nvim/fileio.c:137:5: warning: ‘strncat’ specified bound depends on
the length of the source argument [-Wstringop-overflow=]
  137 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |     ^
src/nvim/fileio.c:137:34: note: length computed here
  137 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |                                  ^
```
2026-05-08 14:47:00 -04:00
Alexej Kowalew
832a68835b fix(shell): preserve CR when :! outputs to binary-mode buffer #39558
Problem:
When `:!` writes shell output to a buffer, write_output() splits on `\r`, `\n`,
and `\r\n`, replacing the terminator byte with NUL. For a binary-mode buffer
this is wrong: `\r` should be preserved verbatim, not treated as a line
terminator. This wrong behavior causes a file like `\r\n` round-trips through
`:%!cat` to `\n`.

This was masked when 'shelltemp' was enabled, because output went through a temp
file and the regular file I/O path handled binary-mode correctly. Switching the
default to 'noshelltemp' exposed the bug, since output is now piped directly
into write_output().

Solution:
In `write_output()`, skip the `\r` and `\r\n` splits for a binary-mode buffer;
only split on `\n`.
2026-05-08 03:54:30 -04:00
zeertzjq
0976ce255b vim-patch:9.2.0450: [security]: heap buffer overflow in spellfile.c read_compound() (#39660)
Problem:  read_compound() in spellfile.c computes the size of the regex
          pattern buffer using signed-int arithmetic on the attacker
          controlled SN_COMPOUND sectionlen.  With sectionlen=0x40000008
          and UTF-8 encoding active the multiplication wraps to 27 while
          the per-byte loop writes up to ~1B bytes, overflowing the heap.
          Reachable when loading a crafted .spl file (e.g. via 'set spell'
          after a modeline sets 'spelllang').  The cp/ap/crp allocations
          have the same int + 1 overflow class (Daniel Cervera)
Solution: Use type size_t as buffer size and reject values larger than
          COMPOUND_MAX_LEN (100000).  Apply the same size_t treatment to
          the cp/ap/crp allocations.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-q4jv-r9gj-6cwv

9299332917

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 23:03:20 +00:00
Justin M. Keyes
b351024daf build(docs): lint more quasi-keysets #39654
Problem:
Linter missed backtick and double-quote keynames in the quasi-keyset of
the `nvim_create_user_command` docstring.

Solution:
Update the linter to check backtick-surrounded and quote-surrounded key
names.
2026-05-07 16:00:26 +00:00
Szymon Wilczek
3639f7a867 feat(server): add v:useractive, use it in serverlist(info=true) #39423
Problem:
When showing the :connect menu, it is useful to know which servers
are most-recently active. But we don't have a good way to detect that.

Solution:
- Introduce `v:useractive`.
- Include this timestamp in `serverlist({info=true})`.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Signed-off-by: Szymon Wilczek <swilczek.lx@gmail.com>
2026-05-07 10:47:51 -04:00
Quentin
97a557bd1e docs: expand nvim_create_user_command docs #39540 2026-05-07 09:18:19 -04:00
Szymon Wilczek
0c3e6e1b0e fix(treesitter): crash in ts_parser_delete after gc #39497
Problem:
parser_gc() calls ts_parser_delete() but leaves the userdata pointer
pointing to freed memory. If the GC finalizer runs at an unexpected time
(e.g. inside nvim_buf_get_lines #39411), a stale pointer could cause a crash.

Solution:
- NULL out `*ud` after ts_parser_delete() in parser_gc()
- Update parser_check() to handle NULL with a clear error message,
guarding all parser methods against UAF

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Signed-off-by: Szymon Wilczek <swilczek.lx@gmail.com>
2026-05-07 08:39:07 -04:00
Justin M. Keyes
df5d559878 Merge #39626 docs 2026-05-07 05:00:55 -04:00
glepnir
1fd82615b1 refactor(excmd): remove duplicate get_cmd_argt (#39643)
Problem:
`excmd_get_argt` and `get_cmd_argt` do the same thing.

Solution:
Drop `get_cmd_argt` and update its callers to use `excmd_get_argt`.
2026-05-07 08:55:30 +00:00
Justin M. Keyes
662c556a3e docs: rename "tabpage" 2026-05-07 10:36:55 +02:00
Justin M. Keyes
80d83d75eb docs: misc, rename "tabpage"
Co-authored-by: michael-grunder <michael.grunder@gmail.com>
Co-authored-by: Olivia Kinnear <git@superatomic.dev>
Co-authored-by: Felipe Matarazzo <felipemps@protonmail.com>
2026-05-07 10:36:48 +02:00
github-actions[bot]
d12dd07c7a docs: update version.c #39466
vim-patch:1de887681 No guidance for AI coding agents
vim-patch:9.2.0421: vimball: can smuggle Vimscript into VimballRecord file
vim-patch:620557bd4 runtime(doc): Update help tags file
vim-patch:9.2.0422: popup: leave stray char when scrollbar changes
vim-patch:9.2.0431: blob encoding can be improved
vim-patch:9.2.0434: cscope: filename interpreted by /bin/sh
vim-patch:9.2.0448: Vim9: dangling cmdline pointer after skip_expr_cctx()
vim-patch:9.2.0449: Make proto fails in non GTK builds


vim-patch:9.2.0409: memory leaks in copy_substring_from_pos()
2026-05-07 03:19:43 -04:00
luukvbaal
dda30fdfbb fix(messages): disallow source="nvim" progress msg #39315
Problem:  Internal progress messages use the "nvim" source (since
          ff68fd6b), plugins shouldn't be allowed to set the progress
          message source to "nvim". The message ID used for internal
          progress messages is not identifiable as such.
Solution: Disallow setting opts->source to "nvim" with nvim_echo().
          Refactor msg_progress() and callees to bypass nvim_echo().
          Prepend message id for internal progress messages with "nvim.".
2026-05-06 12:25:25 -04:00