Problem: Color completion items display as plain text without visual preview
Solution: Parse RGB/hex colors from documentation and render with colored symbol ■
Closing the quickfix window previously triggered a WinClosed autocmd
that deleted all difftool autocmds and pushed an empty quickfix list,
making the difftool non-functional. Users who close the quickfix window
to gain screen real estate for viewing diffs had no way to continue
navigating entries.
Remove the qf_win tracking and its associated WinClosed autocmd so that
closing the quickfix window no longer tears down the difftool state.
Closing either diff window still performs full cleanup as before.
The BufWinEnter handler no longer passes with_qf to diff_files, so
navigating entries while the quickfix window is closed reuses the
existing diff layout without forcing a layout rebuild.
Fixes#37388
Problem: Unable to configure message targets based on message kind.
Solution: Add cfg.msg.targets mapping message kinds to "cmd/msg/pager".
Check the configured target when writing the message.
cfg.msg = { target = 'cmd', targets = { progress = 'msg', list_cmd = 'pager' } }
will for example use the 'msg' target for progress messages,
immediately open the pager for 'list_cmd' and use the cmdline
for all other message kinds.
fix: allocate hidden console for detached server
Starting the server with UV_PROCESS_DETACHED results in DETACHED_PROCESS, leaving the child without a console. Without a console:
CONIN$ / CONOUT$ cannot resolve, causing channel_from_stdio to fail.
ConPTY cannot attach, breaking :terminal.
This patch allocates a hidden console via AllocConsole() when the server has none, restoring working stdio and enabling ConPTY.
Also updates os_set_cloexec to clear HANDLE_FLAG_INHERIT on the RPC pipe
handles, matching the Unix F_DUPFD_CLOEXEC behavior.
Problem: closing a minimal float saves its style-imposed options into
buffer's wininfo, which get picked up by normal windows on :bnext.
Solution: don't save window options to wininfo for style=minimal windows.
Problem:
When cross-compiling, `$<TARGET_FILE:nlua0>` resolves to the target
binary, which cannot run on the host machine during the build process.
Solution:
Allow passing a host native nlua0 binary via
`-DNLUA0_HOST_PRG=/path/to/nlua0` when cross-compiling, so code
generation can run correctly on the host.
Problem: memline: a crafted swap files with bogus pe_page_count/pe_bnum
values could cause a multi-GB allocation via mf_get(), and
invalid pe_old_lnum/pe_line_count values could cause a SEGV
when passed to readfile() (ehdgks0627, un3xploitable)
Solution: Add bounds checks on pe_page_count and pe_bnum against
mf_blocknr_max before descending into the block tree, and
validate pe_old_lnum >= 1 and pe_line_count > 0 before calling
readfile().
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-r2gw-2x48-jj5p65c1a143c3
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: A stack-buffer-overflow occurs when rendering a statusline
with a multi-byte fill character on a very wide terminal.
The size check in build_stl_str_hl() uses the cell width
rather than the byte length, allowing the subsequent fill
loop to write beyond the 4096-byte MAXPATHL buffer
(ehdgks0627, un3xploitable).
Solution: Update the size check to account for the byte length of
the fill character (using MB_CHAR2LEN).
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-gmqx-prf2-8mwf4e5b9e31cb
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: When parsing a malformed Emacs-style tags file, a 1-byte
heap-buffer-underflow read occurs if the 0x7f delimiter
appears at the very beginning of a line. This happens
because the code attempts to scan backward for a tag
name from the delimiter without checking if space exists.
(ehdgks0627, un3xploitable)
Solution: Add a check to ensure the delimiter (p_7f) is not at the
start of the buffer (lbuf) before attempting to isolate
the tag name.
GitHub Advisory:
https://github.com/vim/vim/security/advisories/GHSA-xcc8-r6c5-hvwv9b7dfa2948
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: Crash with overlong emacs tag file, because of an OOB buffer
read (ehdgks0627, un3xploitable)
Solution: Check for end of buffer and return early.
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-h4mf-vg97-hj8jf6a7f469a9
Cherry-pick a change from patch 9.0.0767.
Add missing change from patch 9.2.0070.
Co-authored-by: Christian Brabandt <cb@256bit.org>
Patch 9.2.0033 (vim/vim#19260) introduced a dedicated `env` filetype for
.env files, which were previously detected as `sh`. This left env
files without `commentstring`, `comments`, or `formatoptions` since
no ftplugin was added alongside the new filetype.
Add runtime/ftplugin/env.vim to set these options, matching the
behavior that .env files had when they used the `sh` filetype.
closes: vim/vim#195229148644c1e
Co-authored-by: snelling-a <72226000+snelling-a@users.noreply.github.com>
Problem: tests: various tests leave swapfiles around
Solution: close open buffers using :bw! instead of :close!
2fa34b6422
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: newline escape wrong in ex mode (Konrad Schwarz)
Solution: partly revert patch 7.3.014, remove backslash in front of a
newline when not in prompt mode in ex line mode
(Mohamed Akram)
This fixes newline escaping to allow passing multiple commands to
":global", multiple lines to shell commands, and ending lines in append
mode with backslashes. This should fix a POSIX/(traditional) VI
incompatiblity.
This reverts a previous incorrect attempt at patch v7.3.014 to fix
append mode which removed half of trailing backslashes which lead to,
eg. the following two commands being parsed as having a different number
of backslashes:
```
!echo foo\\\
```
```
!echo foo\\ \
```
fixes: vim/vim#6135fixes: vim/vim#7244closes: vim/vim#15120f3daa4525b
Co-authored-by: Mohamed Akram <mohd.akram@outlook.com>
Problem:
Descriptions of plugins often contain taglinks which are generally
concealed. This misaligns them by 2 characters with descriptions that
don't have a taglink in them.
Solution:
Don't count "bar" characters (`|`) for the description width.
Example:
Actual buffer content:
```
myplugin.txt |lsp| is cool
myplugin.txt this is a nice plugin
```
Rendered as:
```
myplugin.txt lsp is cool
myplugin.txt this is a nice plugin
```
Problem:
vim.fs.joinpath treats empty string as a path segment
(it adds a path separator for each empty item):
print(vim.fs.joinpath('', 'after/lsp', '')) -- '/after/lsp/'
print(vim.fs.joinpath('', '')) -- '/'
Especially problematic if the empty segment is the first segment, as
that converts the path to an absolute path.
Solution:
Ignore empty (length of 0) path segments.
Benchmark:
local function test(func)
local t = vim.uv.hrtime()
for _ = 1, 100000, 1 do
func('', 'this/is', 'a/very/long/path', '', 'it', 'really', 'is')
end
print(math.floor((vim.uv.hrtime() - t) / 1e6), 'ms')
end
- with Iter():filter() --> 370 ms
- building new segments table --> 208 ms
- with vim.tbl_filter --> 232 ms
- Instead of gsub split on `/` in all parts --> 1870 ms
Problem:
libvterm doesn't support parsing the dim and overline attributes, so when a program running in the embedded terminal emits one of these escape codes, we ignore it and don't surface it to the outer terminal.
Solution: tweak libvterm to add support for both attributes.
This makes little difference in practice except for extremely unlikely
ambiguities. But it looks nicer in compiler errors and stacktraces where
you see the fully expanded names
Problem:
Automatic background detection sets the background option too late,
which loads colorschemes twice and causes problems when the user's
terminal background doesn't match the default (#32109, #36211, #36416).
Solution:
Use a DA1 query to determine whether the TTY supports OSC 11. Wait for
background detection and setting to complete before processing user
config.
Note: To preserve the existing behavior as much as possible, this triggers
OptionSet manually on VimEnter (since it won't trigger automatically if
we set bg during startup). However, I'm unsure if this behavior is
truly desired given that the documentation says OptionSet is triggered
"After setting an option (except during |startup|)."
Also fixes flickering issue #28667. To check for flickering:
nvim --clean --cmd "set termguicolors" --cmd "echo \"foo\"" --cmd "sleep 10"
On master, this gives me a black screen for 10 seconds, but on this
branch, the background is dark or light depending on the terminal
background (since the option is now set during startup rather than after
VimEnter).
Problem: When nvim is started with "-s -" (read from stdin), ":restart"
drops the "-" argument but keeps "-s", leaving an orphaned "-s" in the
restarted server's argv, causing a crash.
Solution: Drop "-s" and its scriptfile argument when copying v:argv for
the restarted server. Like "-- [files…]", the scriptfile is a one-shot
startup input that should not be replayed on restart
Problem: Inefficient use of list_append_string()
Solution: Pass string length to list_append_string() where it is known
(John Marriott).
closes: vim/vim#19491455d62e38a
N/A patches:
vim-patch:9.2.0063: memory leak in type_name_list_or_dict()
vim-patch:9.2.0065: memory leak in invoke_sync_listeners()
vim-patch:9.2.0066: memory leak in build_drop_cmd()
vim-patch:9.2.0067: memory leak in dict_extend_func()
Co-authored-by: John Marriott <basilisk@internode.on.net>
Problem:
Regression from b99cdd0:
Pull diagnostics (from `textDocument/diagnostic`) and push diagnostics
(from `textDocument/publishDiagnostics`) use the same namespace, which
is a problem when using language servers that publish two different sets
of diagnostics on push vs pull, like rust-analyzer (see
https://github.com/rust-lang/rust-analyzer/issues/18709#issuecomment-2551394047).
Solution:
Rename `is_pull` to `pull_id` which accepts a pull namespace instead of
just a boolean.
Problem: Not possible to know when a session will be loaded.
Solution: Add the SessionLoadPre autocommand (Colin Kennedy).
fixes: vim/vim#19084closes: vim/vim#193061c0d468d72
Co-authored-by: Colin Kennedy <colinvfx@gmail.com>
Problem: Leading message newlines (not emitted with ext_messages since
4260f73) were responsible for resetting the redirection message
column (while the newline itself is later pruned...).
Solution: Ensure the redirection column is reset at the start of a message.
(Instead of re-adjusting all the newline callsites which can
themselves hopefully be pruned if ext_messages is enabled by
default.)
fix#37867
This bug happens when only one end is moved between different nodes,
but the other end is also moved but within the same node.
When this happens we need the correct previous position even for the
internal move. This code shall be refactored to make the intent clearer,
(and avoid some unnecessary processing) but this is a fix for the observable
bug.
Thanks to KevinGoodsell for providing a deterministic
reproduce using fuzzing techniques.
vim-patch:9.2.0001: tests: Test_popup_setbuf() fails
vim-patch:9.2.0047: Vim9: Comment parsing error with lambda
vim-patch:9.2.0052: Wayland: hiding lower half of command line in tiny vim
Co-authored-by: marvim <marvim@users.noreply.github.com>
Problem: eval_addblob() is inefficient
Solution: Replace per-byte ga_append() loop with a single ga_grow() and
mch_memmove() for each source blob. This eliminates N grow
checks and function call overhead for blob concatenation
(Yasuhiro Matsumoto).
closes: vim/vim#19494c389ae8c44
Omit the pointless int -> long changes in other functions.
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Problem:
If a server is slow with catching up, there can be stale diagnostics
for deleted lines. Then if a user uses `jump` it can error like:
E5108: Lua: ...runtime/lua/vim/diagnostic.lua:670: attempt to index a nil value
stack traceback:
...runtime/lua/vim/diagnostic.lua:670: in function 'get_logical_pos'
...runtime/lua/vim/diagnostic.lua:687: in function 'diagnostic_lines'
...runtime/lua/vim/diagnostic.lua:1122: in function 'next_diagnostic'
...runtime/lua/vim/diagnostic.lua:1665: in function 'jump'
Solution:
Fallback to diagnostic location. That's better than the failure.
Problem: Timer removing a message from the msg buffer does not remove
empty lines if window is closed (col([ui.wins.msg]) fails).
Solution: Use nvim_buf_get_text() to check if line is empty.
The wait added in #37853 doesn't seem to do anything as request is sent
immediately on InsertLeave, and the number 4 also seems wrong. Instead,
the actual cause for the flakiness that the feed() (and hence the buffer
change) may arrive before the scheduled initialization of capabilities,
causing there be only only one textDocument/semanticTokens/full request
instead of two.