Commit Graph

7571 Commits

Author SHA1 Message Date
Justin M. Keyes
52cd9dcff2 Merge #37617 from echasnovski/pack-clearer-lockfile-sync 2026-01-29 16:55:20 -05:00
luukvbaal
1a3d3b77bb fix(ui): no empty message for substitution match with ext_messages #37600
Problem:  Empty message is emitted when a match is found.
Solution: Don't emit it with ext_messages enabled.
2026-01-29 16:51:58 -05:00
Evgeni Chasnovski
164cab405b test(pack): cover that events work when installing from the lockfile 2026-01-29 16:25:02 +02:00
zeertzjq
19a3b67789 fix(process): avoid unexpected behavior when PTY chdir failed (#37614)
Problem:  Unexpected behavior after PTY child process fails to chdir(),
          as it then thinks it's the parent process.
Solution: Exit the child process instead of returning.
2026-01-29 22:02:24 +08:00
zeertzjq
484f455402 test(terminal): status is -1 in TermClose if buffer is deleted (#37609) 2026-01-29 08:29:49 +00:00
zeertzjq
b40880f88f fix(terminal): heap UAF if buffer deleted during TermRequest (#37612)
Problem:  Heap UAF if a terminal buffer is deleted during TermRequest in
          Normal mode.
Solution: Increment terminal refcount before triggering TermRequest, and
          destroy the terminal if the buffer is closed during that.
2026-01-29 13:02:36 +08:00
zeertzjq
97d9b85bf9 fix(terminal): wrong scrollback with BufFile* autocommand (#37601)
Problem:  Wrong terminal scrollback if BufFile* autocommand drains PTY
          output but doesn't process the pending refresh.
Solution: Refresh scrollback before refreshing screen in terminal_open()
          if scrollback has been allocated.
2026-01-28 23:32:58 +08:00
Justin M. Keyes
75114fe7bb Merge #37428 vim.pack tests 2026-01-28 06:48:57 -05:00
zeertzjq
1f0dbfea2f fix(tui): log chdir failure properly #37591 2026-01-28 05:44:17 -05:00
ashab-k
027b7d6bbb fix(ui): :intro not displayed with ui2 #37472
Problem:
The :intro  fails to display in  ui2 because wait_return(true) triggers a full
redraw. Furthermore statuslines are visible when using :intro

Solution:
Replace wait_return() with plain_vgetc(). This works with old and ui2 while also removing the unnecessary statusline and "press ENTER" prompt.
Updates tests to work with new behaviour.

Signed-off-by: ashab-k <ashabkhan2000@gmail.com>
2026-01-27 18:25:36 -05:00
phanium
fd45bc8cab fix: lsp.enable() don't work correctly inside FileType event #37538
Problem:
Two cases lsp.enable() won't work in the first FileType event
1. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim a.lua
```

2. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim -> :edit a.lua -> :mksession! | restart +qa! so Session.vim
```

Solution:
Currently `v:vim_did_enter` is used to detected two cases:
1. "maunally enabled" (lsp.enable() or `:lsp enable`)
2. "inside FileType event"

To detect 2. correctly we use did_filetype().
2026-01-27 17:59:36 -05:00
zeertzjq
6291256868 fix(process): avoid buffering unnecessary UI event with PTY CWD (#37582)
Problem:
Calling os_chdir() to change the child processes' CWD may cause some
unnecessary UI events to be buffered. These UI events don't go anywhere
as execvp() is called before flushing the UI buffer.

Solution:
Use uv_chdir() instead of os_chdir(). Also fix getting error string
incorrectly. Add test for the current behavior.
2026-01-28 06:50:49 +08:00
zeertzjq
df21ac729c fix(terminal): losing output if BufFile* poll for events (#37580)
Problem:  Terminal loses output if a BufFilePre or BufFilePost autocmd
          polls for events.
Solution: Rename the buffer after allocating the terminal instance. Also
          fix buffer getting wrong name if BufFilePre uses NameBuff.
2026-01-28 06:21:28 +08:00
luukvbaal
1d57374c41 fix(ui): textlock still causes issues for UI callbacks #37513
Problem:  There are still ways to run into textlock errors with
          vim.ui_attach callbacks trying to display a UI event.
Solution: Disregard textlock again during vim.ui_attach() callbacks
          (also when scheduled). Partially revert 3277dc3b; avoiding
          to flush while textlock is set is still helpful.
2026-01-27 09:30:37 -05:00
jdrouhard
8ed68fda50 feat(lsp): semantic token range improvements #37451
* cache all tokens from various range requests for a given document
  version
  - all new token highlights are merged with previous highlights to
    maintain order and the "marked" property
  - this allows the tokens to stop flickering once they've loaded once
    per document version
* abandon the processing coroutine if the request_id has changed instead
  of relying only on the document version
  - this will improve efficiency if a new range request is made while a
    previous one was processing its result
* apply new highlights from processing coroutine directly to the current
  result when the version hasn't changed
  - this allows new highlights to be immediately drawable once they've
    processed instead of waiting for the whole response to be processed
    at once
* rpc layer was changed to provide the request ID back in success
  callbacks, which is then provided as a request_id field on the handler
  context to lsp handlers
2026-01-27 08:56:52 -05:00
zeertzjq
b88b7f9591 fix(terminal): wrong colors with nvim_open_term() in non-curbuf (#37579)
Problem:  Wrong colors with nvim_open_term() in non-current buffer.
Solution: Pass the buffer to get_config_string().
2026-01-27 06:59:23 +00:00
zeertzjq
9540e7470b fix(terminal): possible heap-use-after-free during Nvim exit
Usually, terminal_close() calls refresh_terminal(), which allocates the
scrollback buffer, and term_may_alloc_scrollback() in terminal_open()
won't dereference the buffer. However, refresh_terminal() is not called
during Nvim exit, in which case a heap-use-after-free may happen if
TermOpen wipes buffer. Check for non-NULL buf_handle to avoid that.
2026-01-27 13:12:15 +08:00
zeertzjq
b4039ec0b0 fix(terminal): don't allow b:term_title watcher to delete buffer 2026-01-27 12:45:49 +08:00
zeertzjq
b6befc7b03 fix(terminal): losing scrollback when TermOpen polls for events (#37573)
Problem:  When TermOpen polls for enough events to use the scrollback
          buffer, scrollback is lost until the next terminal refresh.
Solution: Allocate the scrollback buffer when it's needed.
2026-01-27 03:46:54 +00:00
luukvbaal
d30d91f3a4 fix(ui): only internal messages are unsafe #37462
Problem:  Fast context for msg_show event inhibits vim.ui_attach from
          displaying a stream of messages from a single command.

Solution: Remove fast context from msg_show events emitted as a result
          of explicit API/command calls. The fast context was originally
          introduced to prevent issues with internal messages.
2026-01-26 18:18:51 -05:00
luukvbaal
96e1acfa42 fix(messages): add "list_cmd" kind to :colorscheme #37561
Problem:  No kind for :colorscheme message.
Solution: Assign it the "list_cmd" kind.
2026-01-26 11:56:39 -05:00
zeertzjq
cc95a7d8b8 vim-patch:8.2.4738: Esc on commandline executes command instead of abandoning it
Problem:    Esc on commandline executes command instead of abandoning it.
Solution:   Save and restore KeyTyped when removing the popup menu.
            (closes vim/vim#10154)

11a57dfd16

No code change is needed in Nvim as Nvim doesn't call update_screen() to
redraw pum.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2026-01-24 10:04:44 +08:00
zeertzjq
b3242af187 vim-patch:9.1.2102: foldtext not reversed and cut off in 'rightleft' mode
Problem:  foldtext not reversed and cut off in 'rightleft' mode
          (bfredl)
Solution: Fix the rightleft redrawing logic (Sergey Vlasov)

fixes:  vim/vim#2659
closes: vim/vim#19220

b51ac5e378

Co-authored-by: Sergey Vlasov <sergey@vlasov.me>
2026-01-24 06:55:54 +08:00
glepnir
589232c0e0 fix(extmark): wrong eol_right_align width calculation (#37034)
Problem: Multiple eol_right_align virtual texts with different widths
are incorrectly positioned. The lookahead loop uses `item` instead of
`lookaheadItem` when checking kind and accessing data, causing all
items to use the first item's width.

Solution: Use `lookaheadItem->kind` and `lookaheadItem->data.vt`
instead of `item->kind` and `item->data.vt` in the lookahead loop.
2026-01-23 08:35:43 +00:00
zeertzjq
196df35cca fix(terminal): <Ignore> should be no-op (#37494) 2026-01-22 09:26:22 +08:00
zeertzjq
25ce44845d fix(terminal): restore options properly when switching buffer (#37485) 2026-01-21 18:42:47 +08:00
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
Evgeni Chasnovski
b4dd11cd5d test(pack): use a helper to vim.pack.add inside testnvim instance
Problem: A lot of test cases require executing `vim.pack.add()` inside
  `testnvim` instance to install and/or add plugins. This requires
  access to the information about tested repo sources (stored in a Lua
  variable inside a runner instance), so it needs to go
  `exec_lua(function() vim.pack.add({...}) end)` route, which in
  formatted form adds two more lines. Since it is very frequent, it pads
  test files with (mostly avoidable and unncessary) lines.

Solution: Add `vim_pack_add()` helper specifically to execute
  `vim.pack.add` inside `testnvim` instance. Use it where possible:
  usually when `vim.pack.add` is not a subject of the test. It is not
  quite doable for some cases, though:
  - When error in `vim.pack.add` is tested.
  - When specification includes `vim.version.range` (since `exec_lua`
    seems to not transfer necessary class metatables).

  This removes ~100 lines from the file at the cost of sometimes using
  `vim_pack_add` and sometimes having to reside to `vim.pack.add`.
  Which seems like a positive trade-off.

  This also allows making a more compact `exec_lua('vim.pack.update()')`
  instructions since `vim.pack.update` doesn't depend on the upvalues
  stored in test runner instance.
2026-01-16 18:49:14 +02:00
Evgeni Chasnovski
0232a63fa5 test(pack): make various small cleanups
Problem: `vim.pack` tests might benefit from a cleanup

Solution: Do the cleanup:
  - Use `t.retry` instead of full `vim.uv.sleep` to make tests quicker.
  - Use `pack_assert_content` helper for a common task of checking the
    content of a special Lua file inside an installed plugin. This is
    used as a proxy of installed plugin's state on the disk.
  - Use `([[...]]):format()` approach (instead of array of strings) in
    one more place. Should improve readability.
2026-01-16 18:31:53 +02: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