Problem: Changing terminal height immediately after outputting lines
may lead to wrong scrollback.
Solution: Insert pending scrollback lines before the old window height.
Problem:
`vim.json.decode()` could not parse JSONC (JSON with Comments)
extension, which is commonly used in configuration files.
Solution:
Introduce an `skip_comments` option, which is disabled by default. When
enabled, allows JavaScript-style comments within JSON data.
Problem: Crash on failed sockconnect() if a new connection is accepted
while polling for uv events.
Solution: Don't use channel_destroy_early().
Also test "tcp" mode failure properly.
Problem:
Escaping logic for {subject} in ex cmd `:help {subject}` is done in a
messy 200+ lines C function which is hard to maintain and improve.
Solution:
Rewrite in Lua. Use `string.gsub()` instead of looping over characters
to improve clarity and add many more tests to be able to confidently
improve current code later on.
Problem: cterm field in Dict(highlight) is declared as Union(Integer, String)
but it actually expects a Dict(highlight_cterm).
Solution: change cterm type to DictAs(highlight__cterm) and simplify the
handling in dict2hlattrs since type validation and empty array compat are
already handled by api_dict_to_keydict.
In particular, also mention the difference between the regex atom \k and
what Vim considers for a word character.
closes: vim/vim#186889e456e52df
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: Wrong scrollback when passing a buffer with many lines to
nvim_open_term().
Solution: Delete all buffer lines before opening the terminal.
I tried to use buf_clear(), but it crashes inside deleted_lines_mark(),
so I'll just use deleted_lines_buf() for now. The behavior of marks can
be decided later.
Problem: heap use-after-free if OptionSet autocommands from setting a terminal's
&buftype wipe the buffer.
Solution: set b_locked during OptionSet for &buftype.
Problem: Terminal doesn't handle ED 3 (clear scrollback) properly.
Solution: Add vterm callback for sb_clear().
Also fix another problem that scrollback lines may be duplicated when
pushing to scrollback immediately after reducing window height, as can
be seen in the changes to test/functional/terminal/window_spec.lua.
Problem: TermResponse deferred due to blocked autocommands lacks "data" payload.
Also, it may not fire if a new v:termresponse reuses the same string address.
Solution: add it. Use the value of v:termresponse for "data.sequence". Replace
pointer comparisons with a flag.
The removal of "old_termresponse" comparisons is required to pass the test on
the CI, or locally for me when compiled in RelWithDebInfo.
Problem: if buf_free_all autocommands open a terminal, it will remain open after
the buffer is freed.
Solution: close terminals again later, this time while blocking autocommands.
Did consider terminal_open checking stuff like b_locked_split instead, but
that's set during BufHidden, etc., which doesn't mean the buffer's being wiped.
Problem: close_buffer autocmds may switch buffers at the last moment when
closing a window, causing terminal_check_size to prefer the size of a closed
window, or TabClosed to set an old <abuf>.
Solution: use the actual last buffer, similar to what TabClosed did before.
NOTE: If buffer was unloaded/deleted (not wiped), then TabClosed's <abuf> may
not use it. (w_buffer = NULL) Maybe odd, but it's how it worked before anyhow.
Relies on close_buffer reliably setting w_buffer to NULL if freed, otherwise
buf_valid is better. Only concern I see is if the window wasn't in the window
list after closing the buffer (close_buffer won't set it to NULL then), but then
win_close{_othertab} should've returned earlier.
Problem: win_free_mem can free w_buffer (via qf_free_all), which may cause a
heap use-after-free if used as TabClosed's <abuf>. I think TabClosed is also the
only event to conditionally set <abuf> not based on event type.
Solution: use the buffer saved by the bufref. Fall back to curbuf if invalid,
like WinResized/WinScrolled.
NOTE: Not always equivalent if close_buffer autocmds switch buffers at the last
moment; previously <abuf> would be set to that buffer. Fixed in next commit.
https://github.com/neovim/neovim/actions/runs/21765657455/job/62800643599?pr=37758#step:9:159
for an example of qf_free_all being a nuisance.
Problem: terminal's size may not update after one of its windows close.
Solution: call terminal_check_size after closing a window.
Disable test for Windows, as for some reason it only shows a few lines...
Problem: Newlines intended to write messages below the cmdline or to
mark the start of a new message on message grid are emitted
through ext_messages. This results in unnecessary newlines for
a UI that has decoupled its message area from the cmdline.
msg_col is set directly in some places which is not transmitted
to msg_show events.
Various missing message kind for list commands.
Trailing newlines on various list commands.
Solution: Only emit such newlines without ext_messages enabled.
Use msg_advance() instead of setting msg_col directly.
Assign them the "list_cmd" kind.
Ensure no trailing newline is printed.
Problem: The following strchar functions have incorrect types:
strcharlen() - Currently any. Always returns an integer, including on
error
strcharpart() - The skipcc annotation does not specify that 0 and 1 are
valid. These inputs are required for vimscript usage. The current
return type is any, even though the function returns an empty string
on error
strchars() - The skipcc annotation does not specify that 0 and 1 are
valid
Solution: Update the problem types.
Problem: In eval.lua, setcharsearch() has an incorrect param type,
causing Lua_Ls to display an error when a valid table is passed.
While getcharsearch correctly states that it returns a table, the type
is non-specific about the contents.
Solution: Update eval.lua with the correct types.
vim-patch:9.1.2111: Vim9: no error for elseif/else after else
vim-patch:9.1.2117: unnecessary braces in terminal.c
vim-patch:602e6042a runtime(doc): Reformat example at :h gui-w32-fullscreen
vim-patch:9.1.2125: MS-Windows: DirectX rendering can be improved
vim-patch:9.1.2127: MS-Windows: DirectX renders font too small
vim-patch:1cac0a575 translation(sv): Remove duplicates from [g]vim.desktop.in
vim-patch:91ec2c3ba CI: update FreeBSD runner to 15.0
Problem: With 'autochdir' win_execute() can corrupt the buffer name,
causing :write to use wrong path.
Solution: Save and restore b_fname when 'autochdir' is active
(Ingo Karkat).
This is caused by a bad interaction of the 'autochdir' behavior,
overriding of the current directory via :lchdir, and the temporary
window switching done by win_execute(), manifesting when e.g. a custom
completion inspects other buffers:
1. In the initial state after the :lcd .. we have curbuf->b_fname =
"Xsubdir/file".
2. do_autochdir() is invoked, temporarily undoing the :lcd .., changing
back into the Xsubdir/ subdirectory.
3. win_execute() switches windows, triggering win_enter_ext() →
win_fix_current_dir() → shorten_fnames(TRUE)
4. shorten_fnames() processes *all* buffers
5. shorten_buf_fname() makes the filename relative to the current
(wrong) directory; b_fname becomes "file" instead of "Xsubdir/file"
6. Directory restoration correctly restores working directory via
mch_chdir() (skipping a second do_autochdir() invocation because
apply_acd is FALSE), but b_fname remains corrupted, with the
"Xsubdir/" part missing.
7. expand("%:p") (and commands like :write) continue to use the
corrupted filename, resolving to a wrong path that's missing the
"Xsubdir/" part.
To fix the problem the short filename is saved if its in effect (i.e.
pointed to by curbuf->b_fname) and 'autochdir' happened. It's then
restored in case of a local cwd override. The conditions limit this
workaround to when 'autochdir' is active *and* overridden by a :lchdir.
closes: vim/vim#19343abb4d74033
Co-authored-by: Ingo Karkat <swdev@ingo-karkat.de>
Problem: :tab sbuffer may close old tabpage if BufLeave autocommand
splits window (after 9.1.0143).
Solution: Only close other windows if the buffer will be unloaded
(zeertzjq).
related: neovim/neovim#37749closes: vim/vim#193526da9f757c4
Problem: windows may scroll horizontally upon resize using the old terminal
size, which may be unnecessary and cause the content to be partially out-of-view.
Solution: reset the horizontal scroll after resizing.
Problem:
$NVIM_APPNAME was not respected when searching $XDG_CONFIG_DIRS for
config files. Nvim hardcoded "nvim" when constructing paths like
`$XDG_CONFIG_DIRS/nvim/init.lua`, ignoring the $NVIM_APPNAME environment
variable.
This meant that config files like `$XDG_CONFIG_DIRS/myapp/init.lua` were
not loaded, even though $NVIM_APPNAME was set to "myapp".
Solution:
Use `get_appname()` instead of hardcoded "nvim" for $XDG_CONFIG_DIRS
paths in `do_system_initialization()` and `do_user_initialization()`.
This makes $XDG_CONFIG_DIRS behave consistently with $XDG_CONFIG_HOME,
which already respected $NVIM_APPNAME.
As documented in `runtime/doc/starting.txt` (L1440-L1441):
"In the help wherever `$XDG_CONFIG_…/nvim` is mentioned it is understood
as `$XDG_CONFIG_…/$NVIM_APPNAME`."
See:
43339dee40/runtime/doc/starting.txt (L1440-L1441)
Relates to #37405
Problem:
The E5422 error message was duplicated in two places in main.c, and
hardcoded error strings should be centralized in errors.h for consistency.
Solution:
Add e_conflicting_configs to errors.h and replace both inline error
strings with the centralized constant.
Problem:
`init.lua` files in `$XDG_CONFIG_DIRS` directories were not being sourced during startup, even though the documentation states they should be searched alongside `init.vim`.
See:
e51f5e17e1/runtime/doc/starting.txt (L495-L496)
Solution:
Modify `do_user_initialization()` to search for `init.lua` in each `$XDG_CONFIG_DIRS` directory before falling back to `init.vim`, matching the behavior for `$XDG_CONFIG_HOME`. Also show `E5422` error if both `init.lua` and `init.vim` exist in the same directory.
Fixes#37405
Problem: Exmode is missing cmdline_block events.
Solution: Emit cmdline_block_show/append when executing a cmdline during
exmode. Emit cmdline_block_hide when leaving exmode.
Problem: Message ID is not incremented without ext_messages.
Solution: Increment where callstack reaches without ext_messages.
There is no clear place marking the end of internal
messages without ext_messages so IDs are only incremented
with `nvim_echo` calls. Message IDs are currently not exposed
anywhere but the msg_show event for this to matter.
Problem: "first" parameter added in 912388f5 for grouping printed lines
in a single event is ineffective for the :global command.
Solution: Only set the message kind for the first printed line during a
:global command.
Problem:
Recombining composing chars in terminal doesn't work at right edge.
Solution:
Check for the case where printing the previous char didn't advance the
cursor. Reset at_phantom when returning to combine_pos.
Problem: Page scrolling in Insert mode beeps (after 9.1.0211).
Solution: Fix incorrect return value of pagescroll(). Also invert the
return value of scroll_with_sms() to be less confusing and
match comments (zeertzjq).
fixes: vim/vim#19326closes: vim/vim#19327a8ce914db1
Problem:
a2b92a5efb is regressive if the
ui_mode_idx set by ui_cursor_shape differs from what ui_flush later sets
it to. (e.g: if mode changes between both calls)
Solution:
Don't overwrite ui_mode_idx to obscure the cursor so that we don't
forget what shape was last set by ui_cursor_shape.
May not be needed, but does fix a potential regression. (and makes it
easier to set ui_mode_idx to something other than cursor_get_mode_idx's
retval in other places, if that's ever wanted)
Problem:
There is no indication of when cursor is "behind" an unfocused, floating window.
Solution:
Set underline cursor to indicate when an unfocused floatwin is over the active cursor.
From the LSP Spec:
> There are two uses cases where it can be beneficial to only compute
> semantic tokens for a visible range:
>
> - for faster rendering of the tokens in the user interface when a user
> opens a file. In this use case, servers should also implement the
> textDocument/semanticTokens/full request as well to allow for flicker
> free scrolling and semantic coloring of a minimap.
> - if computing semantic tokens for a full document is too expensive,
> servers can only provide a range call. In this case, the client might
> not render a minimap correctly or might even decide to not show any
> semantic tokens at all.
This commit unifies the usage of range and full/delta requests as
recommended by the LSP spec and aligns neovim with the way other LSP
clients use these request types for semantic tokens.
When a server supports range requests, neovim will simultaneously send a
range request and a full/delta request when first opening a file, and
will continue to issue range requests until a full response is
processed. At that point, range requests cease and full (or delta)
requests are used going forward. The range request should allow servers
to return a result faster for quicker highlighting of the file while it
works on the potentially more expensive full result. If a server decides
the full result is too expensive, it can just error out that request,
and neovim will continue to use range requests.
This commit also fixes and cleans up some other things:
- gen_lsp: registrationMethod or registrationOptions imply dynamic
registration support
- move autocmd creation/deletion to on_attach/on_detach
- debounce requests due to server refresh notifications
- fix off by one issue in tokens_to_ranges() iteration
Problem: 0x08 is treated as Backspace instead of Ctrl-H on Windows.
Solution: Treat 0x7f as Backspace if VT input is enabled, so that 0x08
is treated as Ctrl-H.
Ref: https://github.com/microsoft/terminal/issues/4949
Problem:
Temporary files from /tmp/ and /private/ paths clutter :oldfiles list.
Additionally, the documented Windows default (rA:,rB:) was never applied
due to a missing platform condition.
Solution:
Drop platform-specific shada differences and default to excluding
/tmp/ and /private/ paths.
problem: currently when empty string is set as prompt the prompt-mark
column doesn't update.
solution: ensure the column is reset to 0 when starting prompt buffer and
before creating a new prompt after prompt-callback.
Problem: Internal messages do not have an ID, which is unexpected and
undocumented.
Solution: Always assign a msg_id to msg_show events, simplifying
logic/expectations for UIs.
Problem: No empty msg_ruler event after leaving a window whose ruler
is not part of the statusline with 'rulerformat'.
Solution: Properly keep track of when a ruler event was emitted with
'rulerformat' to emit clear event.
Problem:
Using vim.defer_fn() just before Nvim exit leaks luv handles.
Solution:
Make vim.schedule() return an error message if scheduling failed.
Make vim.defer_fn() close timer if vim.schedule() failed.