Commit Graph

7543 Commits

Author SHA1 Message Date
zeertzjq
1883fe39bd test: fix some type warnings (#37483) 2026-01-21 15:11:47 +08:00
glepnir
c556972ae1 fix(api): auto-load buffers in nvim_buf_set_* operations (#35046)
fix(api): auto-load buffers in nvim_buf_set_* operations

Problem: Setting marks, lines, or text on unloaded buffers fails because
ml_line_count is not accurate until the buffer is loaded.

Solution: Add require_loaded_buffer() helper and use it in write operations
(nvim_buf_set_lines, nvim_buf_set_text, nvim_buf_set_mark). These now
auto-load buffers as needed.
2026-01-21 14:17:44 +08:00
Kevin Goodsell
2c2203c040 test: fix has() test failure (#37480)
Problem: has("terminfo") test fails on local runs because it expects
"HAVE_UNIBILIUM " in the :version info to mean that nvim was built
without unibilium.

Solution: Assume nvim is built with unibilium if HAVE_UNIBILIUM is
present in the version string and is NOT followed by 0, false, or off.

This isn't affecting CI runs because when the test detects that it is
running in CI it doesn't use the :version string at all.

Resolves https://github.com/neovim/neovim/issues/37456
2026-01-21 12:02:20 +08:00
zeertzjq
1949452bd3 fix(tui): avoid using uv_pipe_t as uv_tty_t (#37479)
Check tui->out_isatty before accessing tui->output_handle.tty.
2026-01-21 11:53:18 +08:00
Tommy Guo
103ddaf9ae fix(lua): correct line number reporting for options set in coroutines (#37463) 2026-01-21 02:18:33 +00:00
zeertzjq
d3aae6172a test: fix flaky tests (#37478)
* test(core/channels_spec): fix flaky test

Always use expect_stdout() to check PTY output.

* test(autocmd/termxx_spec): fix flaky test

Usually the Ctrl-C cancels the following :qa!, but sometimes it doesn't,
and Nvim exits before feed() returns. Instead make sure that :qa! always
reaches Nvim and use expect_exit().
2026-01-21 08:41:00 +08:00
zeertzjq
15b9118ac0 test: fail CI if .nvimlog is not empty (#37470)
This will prevent adding passing tests which logs errors in .nvimlog.

Close #28323
Related: https://github.com/neovim/neovim/pull/27660#issuecomment-2035738597

Co-authored-by: dundargoc <gocdundar@gmail.com>
2026-01-20 20:56:06 +08:00
zeertzjq
6da968dd7f test(core/server_spec): check error in logfile (#37469) 2026-01-20 06:57:10 +00:00
James Fotherby
bfe9fa0f8e fix(socket): remove stale socket files (#37378)
Problem:
Crashed Nvim leaves socket files. Subsequent starts fail with "address already in use".

Solution:
On bind failure, test socket liveness via connect(). Remove if stale, retry bind().

Fixes #36581
2026-01-20 13:59:43 +08:00
glepnir
0712a9c87b fix(pum): separate scrollbar from shadow border (#37448)
Problem:
With shadow border, scrollbar and border overlap. Shadow's right border
starts from the second row (offset by 1), but scrollbar renders on every
row including the first. If they share a column, the first row shows
scrollbar where shadow hasn't started yet, causing misalignment.

Solution:
Separate scrollbar from the shadow's right border.
2026-01-19 19:39:48 -08:00
zeertzjq
8133760c98 test: add tests for #14379 2026-01-20 07:09:15 +08:00
luukvbaal
8bdfd286e5 fix(messages): adjust msg_show "empty" kind logic (#37427)
Problem:  A message ending in an unprintable character may emit a
          msg_show event with the "empty" kind. No empty message event
          for echom "".
Solution: Adjust conditions for emitting "empty" msg_show events.
2026-01-19 17:15:44 +01:00
Emanuel Krollmann
f36dd7557a fix(autocmd): heap UAF with :bwipe in Syntax autocmd
Problem:
Creating an autocommand which executes `:bwipe` on the Syntax event
causes a heap-use-after-free.

Solution: set BF_SYN_SET flag before applying autocommands
2026-01-18 17:56:34 +00:00
glepnir
5a65321684 fix(pum): text overflows into border on truncation (#37438)
Problem:
When text is too long, it overflows into the border. This happens because
grid_line_maxcol includes border columns, so grid_line_puts can write
there.

Solution:
Truncate string to available width when need_fcs_trunc is set.
2026-01-18 08:55:30 +00:00
zeertzjq
41068c77aa fix(normal): assertion failure with "gk" in narrow window (#37444)
When width1 and width2 are negative the assertion may fail. It seems
that adding a negative value to w_curswant won't cause any problems, so
just change the assertion.
2026-01-18 11:46:13 +08:00
Sean Dewar
a5e5ec8910 fix(api): parse_expression crash with unopened ] and node
Problem: nvim_parse_expression null pointer dereference with unmatched ]
followed by a node.

Solution: if ast_stack was empty, set new_top_node_p to top of the stack after
pushing the list literal node; similar to what's done for curlies.

This bug was originally found by a Matrix user, but I couldn't remember how to
trigger it... Ran into the other crash while finding a repro. :P
2026-01-17 13:22:55 +00:00
Sean Dewar
5226801be2 fix(api): parse_expression crash with ident and curly
Problem: nvim_parse_expression null pointer dereference when parsing an
identifier followed by { with "highlight" parameter set to false.

Solution: only set opening_hl_idx if pstate->colors is not NULL.

Not added to parser_tests.lua as that uses highlight = true.
2026-01-17 13:22:55 +00:00
zeertzjq
e51f5e17e1 vim-patch:9.0.0909: error message for layout change does not match action (#37436)
Problem:    Error message for layout change does not match action.
Solution:   Pass the command to where the error is given. (closes vim/vim#11573)

9fda81515b

Thinking about this again, it's actually OK to check split_disallowed in
window_layout_locked(), so add the check.
Also add missing window_layout_locked() in tabpage_close().

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2026-01-17 10:58:26 +08:00
zeertzjq
8754118213 test: remove duplicate test (#37434)
This test is a copy of Test_bufunload_all() and requires too much
additional cleanup for the Windows log message.
2026-01-17 08:31:18 +08:00
Sean Dewar
7e2e116343 fix(api): nvim_get_option_value dummy buffer crashes
Problem: nvim_get_option_value with "filetype" set can crash if autocommands
open the dummy buffer in more windows, or if &bufhidden == "wipe".

Solution: Attempt to close all dummy buffer windows before wiping. Promote the
dummy buffer to a normal buffer if that fails.
2026-01-15 20:08:45 +00:00
Sean Dewar
3cb462a960 fix(api): autocmds mess up nvim_get_option_value's dummy buffer
Problem: When the "filetype" key is set for nvim_get_option_value, autocommands
can crash Nvim by prematurely wiping the dummy buffer, or cause options intended
for it to instead be set for unrelated buffers if switched during OptionSet.

Solution: Don't crash. Also quash side-effects from setting the buffer options.
2026-01-15 20:08:45 +00:00
ashab-k
86c939ba91 fix(treesitter): fix spell navigation on first line (#37361)
Problem:  Spell navigation skips words on the first line because
          _on_spell_nav passes an empty range (0,0) to the highlighter.

Solution: Use math.max(erow, srow + 1) to ensure a valid search window.

Signed-off-by: ashab-k <ashabkhan2000@gmail.com>
2026-01-15 10:20:24 +08:00
zeertzjq
e051718908 fix(process): don't limit PTY master remaining data size 2026-01-15 09:32:10 +08:00
Justin M. Keyes
994444571e test: remove non-actionable tests from "pending" list #37384
Problem:
`t.skip()` adds to the "pending" list. If there is no path to fixing
a pending test, it adds noise to the pending list.

Solution:
Return early instead of using `t.skip()`.
2026-01-14 19:25:11 -05:00
zeertzjq
cabf82be5a test(lsp/diagnostic_spec): fix creating unused clients (#37397)
Fix #36793

Also fix some `integer?` -> `integer` conversion warnings while at it.
2026-01-15 00:23:55 +00:00
zeertzjq
40fb2818b6 vim-patch:9.1.2085: Use-after-free in winframe_remove()
Problem:  Use-after-free in winframe_remove() (henices)
Solution: Set window_layout_locked() inside winframe_remove()
          and check that writing diff files is disallowed when the
          window layout is locked.

It can happen with a custom diff expression when removing a window:

 1. Buffer was removed, so win_frame_remove() is called to remove the
    window.
 2. win_frame_remove() → frame_new_height() → scroll_to_fraction()
    → diff_check_fill() (checks for filler lines)
 3. diff_check_fill() ends up causing a diff_try_update, and because we
    are not using internal diff, it has to first write the file to a
    buffer using buf_write()
 4. buf_write() is called for a buffer that is not contained within a
    window, so it first calls aucmd_prepbuf() to create a new temporary
    window before writing the buffer and then later calls
    aucmd_restbuf(), which restores the previous window layout, calling
    winframe_remove() again, which will free the window/frame structure,
    eventually freeing stuff that will still be accessed at step 2.

closes: vim/vim#19064

ead1dda74a

Nvim doesn't have this bug as Nvim uses a floating window as autocommand
window, and removing it doesn't need winframe_remove().

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-01-14 13:56:01 +08:00
bfredl
5581a53437 fix(shell): ceci n'est pas une pipe
On linux /dev/stdin is defined as a symlink to /proc/self/fd/0
This in turn is defined as a "magic" symlink which is allowed to point
to internal kernel objects which really does not have a file
name. As a glaring inconsistency, fopen("/proc/self/fd/0", "r")
works if fd was originally opened using pipe() but not using
socketpair(). As it happens UV_CREATE_PIPE does not create pipes
but creates socket pairs. These two unfortunate conditions
means that using /dev/stdin and similar does not work in
shell commands in nvim on linux. as a work around, override
libuv's descicion and create an actual pipe pair.

This change is not needed on BSD:s but done unconditionally for simplicity,
except for on windows where it is not done for stdout because of windows

fixes #35984
2026-01-13 09:41:51 +01:00
Justin M. Keyes
9afd81512b Merge #37377 from echasnovski/pack-fix-checkout 2026-01-13 00:07:09 -05:00
Evgeni Chasnovski
bac4cde9cd fix(pack): actually checkout proper version of submodules
Problem: Installing plugin with submodules doesn't check out their
  state (due to `git clone --no-checkout` to not end up with default
  branch code in case of invalid `version`).

  Updating a plugin with submodules doesn't update their state.

Solution: Update `git_checkout` helper to account for submodules.
  Another approach would be `git checkout --recurse-submodules ...`,
  but that doesn't seem to allow `--filter=blob:none` for submodules,
  which is nice to have.

  Also make `git_clone` wrapper simpler since `--no-checkout` makes
  `--recurse-submodules` and `--also-filter-submodules` do nothing.
2026-01-12 22:57:38 +02:00
Evgeni Chasnovski
09edb145f5 test(pack): adjust add startup tests to just sleep with longer timeout
Problem: The `add` startup tests mock startup process which requires
  *some* amount of time to be done. Previous solution with `vim.wait`
  to wait just enough time to register that startup script has finished
  doesn't seem to work as intended (it just wait full time). Its timeout
  is also seems to be barely enough to pass on Windows CI. Which will be
  a problem with more `git` actions done on startup in the future/next
  commit.

Solution: Just sleep predetermined amount of time and explicitly check
  if startup script finished executing.
2026-01-12 22:30:56 +02:00
Tristan Knight
d2ca90d87e fix(glob): handle numeric literals in pattern matching (#37257)
Problem:
vim.glob.to_lpeg() errors when patterns contain numeric literals
(like the '1' in '.ps*1') because LPeg interprets numeric strings
as indexed grammar rule references. For example:
  vim.glob.to_lpeg('.ps*1')
  E5108: Lua: rule '1' undefined in given grammar

Solution:
Prefix all rule names with '_' in the end_seg() function to prevent
literal numbers from being interpreted as LPeg indexed rules. This
ensures pattern components like '1', '2', etc. are treated as
regular rule names rather than special references.
2026-01-12 10:58:01 -08:00
Evgeni Chasnovski
8f0b8a2c27 fix(pack): skip git stash during install
Problem: Installing plugin is done via `git clone --no-checkout ...`
  (to not end up with default branch code in case of invalid `version`).
  This leaves cloned repo in a state that `git stash` will actually add
  an entry to the stash list. Although not critical, better to not have
  that if possible.

Solution: explicitly skip `git stash` step in checkout during install.
2026-01-12 15:53:36 +02:00
zeertzjq
7a6e8d4430 docs: misc (#37281)
Close #37289
Close #37348

Co-authored-by: Marc Jakobi <marc@jakobi.dev>
Co-authored-by: Anton Kesy <anton@kesy.de>
2026-01-12 03:50:57 +00:00
zeertzjq
4399250e90 fix(channel): unreference list after callback finishes (#37358) 2026-01-12 00:33:19 +00:00
Robert Muir
1629493f72 perf(lsp): avoid textDocument/definition requests during tag completion (#37260)
Problem:
vim.lsp.tagfunc looks for the presence of 'c' (cursor) flag and issues
sync textDocument/definition requests to all clients, otherwise
workspace/symbol requests. But 'c' flag can also be set during the
insert mode completion, e.g. with an empty tag completion query, the tag
func receives pattern of '\<\k\k' with flags 'cir'.

Solution:
check for 'i' (insert mode completion) flag and don't issue any LSP
requests, return vim.NIL for immediate fallback to tags.
2026-01-11 14:41:26 -08:00
zeertzjq
94144d4678 fix(lua): vim._with() doesn't save boolean options properly (#37354)
Problem:  vim._with() doesn't save boolean options with false values
          properly.
Solution: Use vim.F.if_nil().
2026-01-11 20:04:32 +08:00
zeertzjq
39d8aa0a1a fix(rpc): don't overwrite already received results on error (#37339)
This fixes a regression from cf6f60ce4d
(possibly), as before that commit a frame is popped from the call stack
immediately after its response is received.

Also fix leaking the allocated error messages.
2026-01-11 17:40:32 +08:00
zeertzjq
2d3dc070ce fix(session): window sizes not stored with float windows (#37344) 2026-01-10 14:28:45 +00:00
glepnir
634f6424aa fix(completion): set 'wrap' and scrolloff=0 in preview window (#37327)
Problem: info/preview floating windows are created
without wrap enabled, causing info text to be
truncated.

Solution: enable 'wrap' and set 'scrolloff' to 0 by
default, like vim's popup_create does.
2026-01-10 16:31:01 +08:00
glepnir
63cbc95d45 fix(api): nvim_set_current_win doesn't reset Visual mode (#37340)
Problem:
Using nvim_set_current_win() to switch windows while in Visual mode
causes E315 ml_get error when target buffer has fewer lines. This
doesn't happen with `:wincmd w` since it properly resets Visual mode
when switching buffers.

Solution:
Reset Visual mode when switching to another buffer, like `:wincmd w`.
2026-01-10 05:49:46 +00:00
zeertzjq
cb77bd1b86 test(server_notifications_spec): improve chanclose test (#37337)
Check that a pending event is actually cancelled, in place of the
nvim_subscribe that was removed in #28487.
2026-01-10 04:12:06 +00:00
zeertzjq
295fb3fdb2 fix(terminal): :edit should respect 'bufhidden' with exited job (#37301) 2026-01-10 08:25:49 +08:00
zeertzjq
aa959f7b85 vim-patch:9.1.2069: Search wrap indicator not shown w/out 'shm-S' (#37332)
Problem:  when shortmess doesn't have 'S', backward search wrap doesn't
          show the "W" before count. forward search works fine but
          backward fails because the position check logic is backwards -
          it checks if cursor < pos instead of using the existing
          wrapped flag.
Solution: Use sia->sa_wrapped flag that searchit() already sets
          correctly (glepnir).

fixes:  vim/vim#5280
closes: vim/vim#19138

ccb7b43365

Co-authored-by: glepnir <glephunter@gmail.com>
2026-01-10 08:03:10 +08:00
Yochem van Rosmalen
f19653e370 fix(health): emit Progress message #37123
Problem:
The `"Running healthchecks..."` message doesn't inform the user much and
is a hack from before we got a way to emit actual progress messages.

Solution:
Use `nvim_echo` to emit progress messages showing the name of the report
that is currently running.
2026-01-09 17:00:09 -05:00
zeertzjq
445cb751e6 fix(pum): pumborder=shadow not blending properly (#37328)
Problem:  Setting pumborder=shadow doesn't blend proerly.
Solution: Check fconfig.shadow when setting pum_grid.blending, like what
          is done in check_blending().
2026-01-09 11:52:59 +00:00
zeertzjq
49d7f694a8 fix(:ls): check for finished terminal properly (#37303)
Use terminal_running() instead of channel_job_running().
2026-01-09 01:31:00 +00:00
zeertzjq
885426f1bf vim-patch:9.1.2064: completion: segfault during file name completion (#37316)
Problem:  completion: segfault during file name completion
Solution: Initialize compl_num_bests (Girish Palya)

closes: vim/vim#19134

4895ae8c0c

Co-authored-by: Girish Palya <girishji@gmail.com>
2026-01-09 08:43:10 +08:00
zeertzjq
681d006549 vim-patch:9.1.2066: :wqall! doesn't close a terminal like :qall! does (#37314)
Problem:  :wqall! doesn't close a terminal buffer like :qall! does
          (after 8.0.1525).
Solution: Check eap->forceit (zeertzjq).

Ref: https://github.com/vim/vim/issues/2654#issuecomment-366803932

related: vim/vim#2654
related: neovim/neovim#14061
closes:  vim/vim#19129

d8558fdf4f
2026-01-08 23:36:47 +00:00
zeertzjq
0bd4d3f779 test(terminal/buffer_spec): fix flaky test (#37299)
It turns out that uv_write() doesn't queue the write if there are no
pending writes, so vim.uv.run() isn't needed to reproduce the crash.
2026-01-08 02:40:04 +00:00
zeertzjq
bfb70c03ff test(buffer_updates_spec): move on_detach tests to its block (#37297) 2026-01-08 09:59:27 +08:00