Commit Graph

20836 Commits

Author SHA1 Message Date
Maria Solano
09a4cc8c50 fix(docs): multi-level list dedent indentation #40850
Problem:
The list-item indentation logic in `gen_help_html.lua` tracks `opt.indent` that
only decrements by one level when a list item is less indented than its sibling.
Dedenting across multiple nesting levels at once produces the wrong left margin.

Solution:
Track the exact leading whitespace for each indent level in a `opt.indent_ws` stack:
- On reset or a top-level item initialize the stack with the current item's
  whitespace.
- When indenting deeper push the current whitespace at the new level.
- When dedenting pop every level whose tracked whitespace is deeper than the
  current item (reaching the correct ancestor level).
2026-07-20 05:02:17 -04:00
Barrett Ruth
a787a31490 fix(window): avoid UAF in close_windows (#40853) 2026-07-20 07:48:36 +00:00
Barrett Ruth
1dffa35d46 build(deps): bundle tree-sitter-diff parser #40778 2026-07-19 19:55:20 -04:00
Jan Edmund Lazo
d2a3e0e881 vim-patch:8.2.2271: ml_get error when changing hidden buffer in Python (#40833)
Problem:    ml_get error when changing hidden buffer in Python.
Solution:   Block updating folds. (closes vim/vim#7598)

----

"ctx_switch()", "ctx_restore()" obsolete "switch_buffer()" and
"restore_buffer()".
Latter are unused since https://github.com/neovim/neovim/pull/15831.
Mark them as N/A (until some test fails).

----

3e0107ea16

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2026-07-19 19:51:47 -04:00
Willaaaaaaa
689b45dda3 fix(write): show E17 on all platforms #40595
Problems:
On Windows, `:w somedir` (where somedir is an existing directory
in pwd) shows the misleading `E13: File exists (add ! to override)`
instead of `E17: "somedir" is a directory`.

Solution:
drop unnecessary `#ifdef` guard.
2026-07-19 15:42:59 -04:00
Sébastien Hoffmann
7ba955fe07 fix(statusline): prevent integer overflow with huge item groups #40837
Problem: when PR #40621 removed a 50 cell restriction to item group
minwid, a possible integer overflow was introduced when the added
padding is multiplied with the number of fillchar bytes.

Solution: when there is not enough buffer capacity left, reduce the
number of added fillchars before calculating the number of added bytes.
2026-07-19 13:29:57 -04:00
Justin M. Keyes
d1b3a9924d feat(api): mark nvim_create_autocmd as api-fast #40836
Problem:
nvim_create_autocmd() isn't |api-fast|, so modules that create autocmds
(e.g. vim.treesitter.query) can't be require()d in a fast event context.

Solution:
Mark it |api-fast|. Compile autocmd patterns with RE_NOBREAK so
aucmd_next() won't os_breakcheck() mid-iteration, where a fast
nvim_create_autocmd() could realloc the autocmds vector and dangle the
caller's AutoPat/AutoCmd.

RE_NOBREAK is low-risk because:
- aucmd_next()'s loop checks CTRL-C: `(for (… i < apc->ausize && !got_int; …)`.
- `line_breakcheck()` (`autocmd.c:1912`) runs once per matched autocmd.
- Each autocmd _execution_ runs through `do_cmdline`, which has its own
  breakchecks.

However this does admit risk of a pathological case:
a catastrophic-backtracking glob matched against a very long `User`
event-pattern.

Co-authored-by: Riley Bruins <ribru17@hotmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-07-19 11:38:14 -04:00
Artem Krinitsyn
746f5682a7 fix(ui): combine float border with window background #40796
Problem:
Float border highlight groups (FloatBorder, FloatTitle and FloatFooter)
fall back to Normal background highlight if no background color set.

Solution:
Combine border colors with window-local Normal highlight.

Fix #38330
2026-07-19 11:03:46 -04:00
Justin M. Keyes
851656c628 fix(coverity): STRING_OVERFLOW #40835
CID 651340:         Security best practices violations  (STRING_OVERFLOW)
    /src/nvim/keycodes.c: 383             in get_special_key()
    377             data->key = *s;
    378             data->key_alt = (String){ NULL, 0 };
    379           }
    380         }
    381
    382         if ((int)s->size + idx + 2 <= MAX_KEY_NAME_LEN) {
    >>>     CID 651340:         Security best practices violations  (STRING_OVERFLOW)
    >>>     You might overrun the 33-character fixed-size string "string + idx" by copying "s->data" without checking the length.
    383           STRCPY(string + idx, s->data);
    384           idx += (int)s->size;
    385         }
    386       }
    387       string[idx++] = '>';
    388       string[idx] = NUL;
2026-07-19 14:07:18 +00:00
Justin M. Keyes
239125b8c8 feat(eval): declare more "fast" functions #40834 2026-07-19 10:03:53 -04:00
github-actions[bot]
f3ba77ab86 docs: update version.c #40829
vim-patch:8.2.4945: inconsistent use of white space
vim-patch:9.0.1590: filetype test has trailing white space
vim-patch:9.0.1916: Crash when allocating large terminal screen
vim-patch:d086b8f64 runtime(doc): fix inconsistent indent (#14089)
vim-patch:59356019e runtime(doc): align command line table
vim-patch:112505104 runtime(doc): CI: remove trailing white space in documentation
vim-patch:3ca914ec7 runtime(doc): Tweak documentation style a bit
vim-patch:9.1.1352: style: inconsistent indent in insexpand.c
vim-patch:9.1.1363: style: inconsistent indentation in various files
vim-patch:9.1.1366: v9.1.1364 unintentionally changed sign.c and sound.c
vim-patch:45b59a92c runtime(doc): remove trailing whitespace from example in builtin.txt
vim-patch:9.2.0003: tests: invalid indent in message.c
vim-patch:467fe6581 CI: Bump the github-actions group across 1 directory with 2 updates
vim-patch:9.2.0798: Memory leak in compile_expr6() on alloc failure
vim-patch:9.2.0799: Memory leak in compile_def_function_body() on alloc failure

Co-authored-by: marvim <marvim@users.noreply.github.com>
2026-07-19 07:07:03 -04:00
Justin M. Keyes
6f5fae3f8c fix(lua): vim.keycode cleanup #40817 2026-07-18 14:31:36 -04:00
altermo
a2dfa195b2 feat(lua): vim.keycode() gets structured parse result #38636
Problems:
1. Can't get individual parts of a key-chord separately: modifiers, key.
2. Can't separate a key-combo into individual key-chords.

Solution:
Enhance `vim.keycode()` to optionally return a structured parse result
as a list of key-chords:
- `key_raw` the key-chord (problem 2)
- `mod` the modifiers of `key_raw` (problem 1)
- `key_orig` the key part of the key-chord, only here if differing from `key`
  (this doesn't solve any of the above mentioned problems, but it may provide
  useful and it's (in terms of code) free)
- `key` a normalized version of `key_orig` (solving problem 1), example(the
  first is `key_orig` and second is `key`): `lt` and `<`, `Bar` and `|` (in
  `<C-Bar>`)
2026-07-18 12:20:41 -04:00
zeertzjq
952e59347e vim-patch:9.2.0796: Visual block reselection wrong with 'virtualedit' (#40815)
Problem:  Visual block reselection wrong with 'virtualedit' when line
          lengths are different (Alex Yang, after 8.2.3494).
Solution: Set the entire cursor position to old position when computing
          target curswant, since the check_cursor() added in 8.2.3494
          may change cursor column as well (zeertzjq).

fixes:  vim/vim#20746
closes: vim/vim#20748

8cddbfe468
2026-07-18 23:10:03 +08:00
zeertzjq
8a87b4cc67 vim-patch:9.2.0794: extend() and extendnew() don't handle NULL expr2 properly (#40814)
Problem:  extend() and extendnew() don't handle NULL expr2 properly
          (Mao-Yining)
Solution: Still set the return value when expr2 is NULL (zeertzjq).

fixes:  vim/vim#20758
closes: vim/vim#20759

e397c82a04
2026-07-18 23:09:45 +08:00
zeertzjq
650299fba0 vim-patch:9.2.0787: regexp: code 0x1ecb duplicated for equivalence class (#40808)
Problem:  regexp: code 0x1ecb duplicated for equivalence class
          (Sami Farin)
Solution: Remove it

fixes:  vim/vim#8029#issuecomment-4998990223
closes: vim/vim#20782

c7feefe170

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-07-18 14:32:30 +00:00
Justin M. Keyes
446b9d8c55 docs: misc, remove some old help tags #40214
- Remove old help tags: they add noise to cmdline completion.

Co-authored-by: acehinnnqru <acehinnnqru@gmail.com>
Co-authored-by: KangaZero <samuelyongw@gmail.com>
Co-authored-by: Simone Ragusa <hi@interrato.dev>
Co-authored-by: Chinmay Dalal <~chinmay/public-inbox@lists.sr.ht>
Co-authored-by: coyaSONG <66289470+coyaSONG@users.noreply.github.com>
Co-authored-by: Olivia Kinnear <git@superatomic.dev>
2026-07-18 04:29:51 -04:00
github-actions[bot]
1cb0bbe798 docs: update version.c #40783
vim-patch:98056533b Vim 8.2 release
vim-patch:495282b6e Correct list of patch numbers
vim-patch:85d9b03f8 Correct list of patches.
vim-patch:8.2.2598: Vim9: :open does not need to be supported
vim-patch:8.2.4606: test fails because of changed error message
vim-patch:9.0.0014: missing part of the test override change
vim-patch:9.0.0515: virtual text highlight starts too early when 'number' is set
vim-patch:9.0.0516: virtual text "above" highlights gap after it
vim-patch:9.0.0518: virtual text highlight starts too early with 'nowrap'
vim-patch:9.0.0698: VisVim is outdated, does not work with current Visual Studio
vim-patch:9.0.0833: Mac: no +sound feature in huge build
vim-patch:9.0.1124: virtual text at a column position is truncated
vim-patch:9.0.1463: virtual text truncation only works with Unicode 'encoding'
vim-patch:9.0.1482: crash when textprop has a very large "padding" value
vim-patch:9.0.1695: Crash with overlong textprop above
vim-patch:9.1.0139: MS-Windows: ligatures map cleared on startup
vim-patch:9.1.0368: MS-Windows: Hard to define the Vim Patchlevel with leading zeroes
vim-patch:20393bc02 runtime(doc): update last change date for diff.txt
vim-patch:c49cb93a8 patch 9.1.1392: missing patch number
vim-patch:9.1.1397: tabpanel not correctly updated on :tabonly
vim-patch:9.1.1530: Missing version change in v9.1.1529
vim-patch:689f3bf31 runtime(doc): clarify C99 constraints and portability assumptions
vim-patch:9.1.1589: Cannot disable cscope interface using configure
vim-patch:9.1.1637: FEAT_DIFF used in diff.pro
vim-patch:2d4eb6ee1 runtime(doc): Remove dead link from todo.txt
vim-patch:6d8307fc2 runtime(doc): Add a Development policy
vim-patch:9.1.1982: Use after free with redraw_listener_add()
vim-patch:9.1.2084: Compile error when build with job feature
vim-patch:9.1.2115: CI: wrong preprocessor indentation
vim-patch:9.2.0764: Compiler warning about unused function
vim-patch:b212f440a CI: Bump the github-actions group across 1 directory with 2 updates

Co-authored-by: marvim <marvim@users.noreply.github.com>
2026-07-18 04:20:48 -04:00
Barrett Ruth
12e8db3847 fix(restart): distinguish v:exitreason for :restart! #40801 2026-07-18 04:07:14 -04:00
Kyle
28818702e9 fix(tui): urxvt reset cursor style #40800
Problem:
urxvt doesn't support resetting to default cursor style like we assumed.
https://github.com/neovim/neovim/issues/38987#issuecomment-5004636437

Solution:
Instead of the reset sequence, always set it to steady block. This will
still be wrong for users who configured their initial cursor to
underline, but it's about the best we can do.
2026-07-17 21:07:58 -04:00
Justin M. Keyes
e0e7f65b74 refactor(detach): eliminate nvim__ui_detach #40793
Problem:
`nvim__ui_detach` was added in 85e0559d46 in order to implement
`detach_others` from Lua. Using Lua in this case is doing more harm than
good.

Solution:
Extract `ui_detach_channel`, which also allows it to be used for the
"self detach" path from `ex_detach`.

Bonus: the old MSWIN path always called `os_swap_to_hidden_console()`;
now `ui_detach_channel` only does so for a stdio channel. For the common
stdio TUI this is identical; for a socket UI it's more correct (no
parent console to swap).
2026-07-17 16:37:45 -04:00
Jason Woodland
85e0559d46 feat(ui): ":%detach!" detaches all other UIs #39216
Problem:
Not easy for one UI to kick the others off a shared Nvim server.

Solution:
Treat `:%detach` as detach-other-UIs.
2026-07-17 15:23:34 -04:00
MAAZIZ Adel Ayoub
9d3edf345f fix(path): avoid shell fallback for unknown users #40757
Problem:
Expanding an unknown ~user path falls back to the shell. In a fast event,
this re-enters the event loop and aborts Nvim.

Solution:
Leave unknown users unexpanded when the system account lookup fails.
2026-07-17 14:21:29 -04:00
Olivia Kinnear
ed5dcc0edf fix(restart): messages EXX error codes #40759 2026-07-17 13:52:56 -04:00
Justin M. Keyes
d36d05cbd5 refactor(globals): group Visual-mode globals in VisualState #40777 2026-07-16 20:38:44 -04:00
Justin M. Keyes
81926f04b4 refactor(search): SearchState 2026-07-16 21:39:40 +02:00
carladams1299-lab
b80e01e10a refactor(globals): group search state into SearchState struct 2026-07-16 21:35:01 +02:00
Curnic Dorin
a297985d05 fix(messages): show hint in E77 error #40765 2026-07-16 10:23:27 -04:00
Jan Edmund Lazo
16c25e8aee vim-patch:8.2.4955: text property in wrong position after auto-indent (#40766)
Problem:    Text property in wrong position after auto-indent.
Solution:   Adjust text property columns. (closes vim/vim#10422, closes vim/vim#7719)

788c06a249

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2026-07-16 06:48:20 +00:00
Sean Dewar
1741da8412 fix(window): yeet grid later when closing float in other tabpage #40758
Problem: #40731 may still crash if close_buffer autocmds reinsert the float's
grid. Plus removing the grid (and posting win_close) is unneeded if
win_close_othertab refuses to close the window later, which is possible.

Solution: do the stuff before freeing the window, like win_close.
2026-07-15 19:09:54 -04:00
glepnir
5ce9e74f13 feat(completion): commitCharacters #38417
Problem: LSP completion commitCharacters are not handled. Typing a
commit character (e.g. `.`, `(`, `;`) while a completion item is
selected does not accept the item first.

Solution: Store commit characters as a flat string in complete-items.
Check it before completion stops, accept the match and let
the character be inserted normally.
2026-07-15 19:08:37 -04:00
Justin M. Keyes
31ad7d4527 Merge #40621 fix(ui2)!: legacy 'ruler' inconsistencies 2026-07-15 08:13:37 -04:00
phanium
6f370f34f2 fix(window): remove float grid from compositor layers before free #40731
Problem: Closing a floating window from a non-current tab frees its grid
without removing it from the compositor's `layers` table, so the next
`ui_comp_put_grid()` walks a dangling pointer (UAF).

Solution: Call `ui_comp_remove_grid()` (and `ui_call_win_close()` for
multigrid UIs) before `win_free_mem()`, matching `win_close()` since
PR #21551.
2026-07-15 07:48:34 -04:00
Barrett Ruth
b2570e6852 fix(showcmd): avoid stale %S contents #40747
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-07-15 06:10:09 -04:00
Justin M. Keyes
671e9d4913 feat(marks): :marks completion, list extmarks #40743
Problem:
- No UI for listing extmarks.
- `:marks` doesn't support cmdline-completion.

Solution:
- Add completion and extmarks support to `:marks`.
- Update `get_buf_local_marks` to include the ":" (prompt-buffer) mark.
2026-07-15 05:55:51 -04:00
zeertzjq
39bc59a8f1 fix(floatwin): don't use same window as altwin (#40748)
Fixes a regression from #34486
Fix #40745
2026-07-15 05:59:45 +00:00
Justin M. Keyes
eb94149a29 refactor(vimscript)!: drop ctxget(), ctxpush(), etc #40724
Problem:
This functions are most likely never used in the wild.
- They are redundant with `nvim_get_context` + `nvim_load_context`.
- The "context" concept was never fully developed and hasn't gained
  traction.

Solution:
Drop these vimscript aliases, they are just extra cruft.
2026-07-13 17:57:13 -04:00
Justin M. Keyes
06ded1330c refactor(core): group Visual-mode globals in VisualExtent #40722 2026-07-13 16:19:32 -04:00
Barrett Ruth
73bb6a8a5e fix(dir): let 3P dir-browser plugin rename the dir buffer #40529
Problem:
`FileType directory` fires *before* the `BufEnter` path where `dir.lua`
populates the buffer, in order to allow a 3P dir-browser plugin to handle the
event and (optionally) rename the buffer to e.g. `example:///tmp/foo/`.

But currently, `open_buffer()` continues after `filetypedetect BufRead` as if
the original directory buffer is *still* current and valid, which may fall
through to the built-in `nvim.dir` path after a 3P plugin ALREADY handled the
directory.

Solution:
Keep a buf ref around the early `filetypedetect BufRead` call for directory
buffers.

If the `FileType directory` handler switches away from/deletes the original
directory buffer, stop the open path instead of continuing into the built-in
`nvim.dir` flow.
2026-07-13 15:10:19 -04:00
Justin M. Keyes
fe794153ed feat(docs): mark optional API parameters 2026-07-13 20:01:55 +02:00
Justin M. Keyes
9982f6e0e4 refactor(api): omit optional param 2026-07-13 19:44:15 +02:00
Justin M. Keyes
dc8934482e feat(api): optional params after opts #40720
Problem:
After 25439dad7e, `opts` is optional, but not params that follow it.

Solution:
- Update `gen_api_dispatch.lua`, docs, tests.
- Enhance the `nvim_get_api_info()` api-metadata to include a boolean
  flag indicating whether a parameter is optional:
  ```
  [type, name, optional]
  ```

Note: Currently, optional params are assumed to be Dict/Array. Since we
don't yet have any use-cases of optional params following `opts`, the
build just checks this assumption and we can deal with it later if we
ever care to:

    nvim_get_hl: optional param "foo" has type "Integer" but (currently)
    we assume Dict/Array
2026-07-13 13:43:49 -04:00
Barrett Ruth
25439dad7e feat(api): relax contract, opts + rest params are optional #40581
Problem:
|api-contract| allows adding an optional trailing `opts` parameter, but
the dispatch generator still requires every parameter, so `opts` cannot
be omitted.

Solution:
Treat a trailing `Dict(...) *opts` parameter as optional in the generated
RPC and Lua dispatch wrappers.

Co-authored-by: Judit Novak <judit.novak@gmail.com>
2026-07-13 10:28:24 -04:00
Barrett Ruth
1665b992b7 fix(filetype): trigger FileType after BufReadCmd #40679
Problem:
A successful `BufReadCmd` can leave an existing `filetype` without
rerunning its `FileType` setup, so state cleared during reload may not
be restored.

This also causes `:edit`/reload syntax `directoryDirectory` groups to
not be reapplied.

Solution:
After `BufReadCmd` handles a read, trigger `FileType` for the existing
`filetype` if no `FileType` event fired during the read.
2026-07-13 09:08:09 -04:00
Justin M. Keyes
6ea01d37f8 refactor(core): group insert-mode globals in InsState #40712
Problem:
Insert-mode globals are scattered.

Solution:
Group them into one struct. Besides improving readability and
discoverability, this greatly helps with save/restore of an insert-mode
session.
2026-07-13 09:06:04 -04:00
Justin M. Keyes
e1c1bd3722 fix(coverity): RESOURCE_LEAK, USE_AFTER_FREE
/src/nvim/ex_docmd.c: 5033             in ex_restart()
    5027         // The address after --listen may be in use by the current server.
    5028         if (i > 0 && strequal(arg, "--listen")) {
    5029           const listitem_T *next_li = li->li_next;
    5030           if (next_li != NULL) {
    5031             const char *addr = tv_get_string(TV_LIST_ITEM_TV(next_li));
    5032             if (strstr(addr, ":") || strstr(addr, "/") || strstr(addr, "\\")) {
    >>>     CID 649201:         Resource leaks  (RESOURCE_LEAK)
    >>>     Overwriting "listen_arg" in "listen_arg = xstrdup(addr)" leaks the storage that "listen_arg" points to.
    5033               listen_arg = TO_SLASH_SAVE(addr);
    5034     #ifdef MSWIN
    5035               // On Windows, don't pass --listen to new server (named pipe can't be reused immediately).
    5036               // Instead pass the address via RPC; new server rebinds after startup.
    5037               li = next_li;
    5038               continue;

    *** CID 649200:         Memory - illegal accesses  (USE_AFTER_FREE)
    /src/nvim/eval/fs.c: 228             in modify_fname()
    222
    223       // ":h" - head, remove "/file_name", can be repeated
    224       // Don't remove the logical root, see `FileInfo`.
    225       while (src[*usedlen] == ':' && src[*usedlen + 1] == 'h') {
    226         valid |= VALID_HEAD;
    227         *usedlen += 2;
    >>>     CID 649200:         Memory - illegal accesses  (USE_AFTER_FREE)
    >>>     Using freed pointer "s".
    228         while (tail > s && after_pathsep(s, tail)) {
    229           MB_PTR_BACK(*fnamep, tail);
    230         }
    231         *fnamelen = tail <= s ? (size_t)(s - *fnamep) : (size_t)(tail - *fnamep);
    232         if (*fnamelen == 0) {
    233           // Result is empty.  Turn it into "." to make ":cd %:h" work.
2026-07-13 05:48:05 +02:00
Justin M. Keyes
3a7989f4f4 docs(shada): outdated docstrings #40711 2026-07-12 22:42:47 -04:00
tao
4a08596314 fix(path): normalize separators (slashes) #39155
Problem:
Continue separators normalization, and try to keep it at the
nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx`

Solution:
some key changes
- normalize `$HOME-windows`
- normalize entry points of changing directory
  - `nvim_set_current_dir()`, `chdir()`
- normalize the named pipe
  - `--listen` arg, `--server` arg, `:restart`
  - `serverstart()`, `sockconnect()`, `serverstop()`
- make `expand()` respect 'shellslash' again
- clean up `did_set_shellslash`
- replace `forward_slash` with `TO_SLASH`
- remove obsolete `TMP_PATHSEPSTR`
- remove `slash_adjust` in `do_autocmd_dirchanged`?
- make `fnamemodify()` always return `/` (except when substituting
  separators via `:s`, `:gs` ?)

Note:
- these funcs still apply `slash_adjust` on return, as before:
  `:pwd`, `chdir()`, `exepath()`, `getcwd()`
- these funcs alwarys return `/`, unlike before the normalization PRs
  - `getcompletion()`, `finddir()`, `findfile()`

Also
- clean up code, comments, formatting and tests
- move `TO_SLASH` from `f_chdir` to `changedir_func`
- move `TO_SLASH` from `f_bufadd` to `buflist_new`

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-07-12 13:23:44 -04:00
glepnir
58b6310adc fix(startup): respect enter for windows created in startup scripts #37287
Problem: When a split window is created from the init script using nvim_open_win()
with enter=false, the current window focus is not preserved. The cursor
incorrectly moves into the newly created split during startup.

Solution: Save curwin before the iteration loop in create_windows(), and
restore it after the loop. also update edit_buffers() to use curwin instead
of firstwin.
2026-07-12 12:30:40 -04:00
Justin M. Keyes
81c4c295ac refactor(insert): rename edit.c => insert.c #40705
Problem:
- `edit.c` is an unnecessarily misleading and less-discoverable name
  than `insert.c`.
- Numerous insert-mode related things are named with a `ins_` prefix.
- There is already a `insexpand.c` module...

Solution:
Rename `edit.c` => `insert.c`.
2026-07-12 11:57:17 -04:00