vim-patch:9.2.0174: diff: inline word-diffs can be fragmented
Problem: When using 'diffopt=inline:word', lines were excessively
fragmented with punctuation creating separate highlight
blocks, making it harder to read the diffs.
Solution: Added 'diff_refine_inline_word_highlight()' to merge
adjacent diff blocks that are separated by small gaps of
non-word characters (up to 5 bytes by default) (HarshK97).
When using inline:word diff mode, adjacent changed words separated by
punctuation or whitespace are now merged into a single highlight block
if the gap between them contains fewer than 5 non-word characters.
This creates more readable diffs and closely matches GitHub's own diff
display.
closes: vim/vim#1909842c6686c78
Problem: possible crash with winminheight=0
(Emilien Breton)
Solution: Use <= instead of < when checking reserved room in
frame_setheight() to correctly handle the zero-height
boundary case (Hirohito Higashi).
In frame_setheight(), when shrinking the current window and the only
other window has 'winfixheight' with 'winminheight'=0, room_reserved
was not cleared because the condition used '<' instead of '<='.
The freed rows were discarded, leaving fr_height sum less than
topframe fr_height. Subsequent resize operations then computed a
wrong room_cmdline that expanded topframe beyond the screen, causing
a crash.
fixes: vim/vim#19706closes: vim/vim#19712a5d9654620
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Problem:
The 'android' and 'termux' feature flags have been shipped in the
downstream neovim/neovim-nightly package for 5+ years but were never
properly documented in the downstream patch.
Solution:
Upstream the 'android' and 'termux' feature flags into Neovim as
decoupled feature flags, this enables the 'android' feature in
particular to be available independently of the 'termux' feature
for builds of Neovim against the Android NDK, but not including
the Termux NDK patchset.
Co-authored-by: Lethal Lisa <43791059+lethal-lisa@users.noreply.github.com>
Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>
Problem: autocmds that switch windows may cause them to remain with
w_locked set, preventing them from being closed longer than
intended.
Solution: Unset w_locked in the window where it was set (Sean Dewar).
closes: vim/vim#19716bae31c35bb
Also move alist_add_list's ga_grow inside the if block, so it's only called when
check_arglist_locked is OK, like Vim.
I also notice a redundant return at the end of the block; could be useful if
more code is added later, so I'm leaving it.
Problem:
No way to disable progress messages in cmdline message area. If
a third-party plugin handles Progress events + messages, the user may
not want the "redundant" progress displayed in the cmdline message area.
Solution:
Support "progress:c" entry in 'messageopts' option.
Problem: nvim_open_tabpage's "enter" argument is optional, which is inconsistent
with nvim_open_win.
Solution: make it a (non-optional) positional argument, like nvim_open_win.
Also change "enter"'s description to be more like nvim_open_win's doc.
Problem: "after" in nvim_open_tabpage is inconsistent with how a count works
with :tab, :tabnew, etc. Plus, the name "after" implies it's inserted after that
number.
Solution: internally offset by 1. Allow negative numbers to mean after current.
Hmm, should we even reserve sentinels for after current? Callers can probably
just use nil...
- Cleanup, remove redundant comments, add more tests.
- Enhance win_new_tabpage rather than create a new function for !enter, and use
a different approach that minimizes side-effects. Return the tabpage_T * and
first win_T * it allocated.
- Disallow during textlock, like other APIs that open windows.
- Remove existing win_alloc_firstwin error handling from win_new_tabpage; it's
not needed, and looks incorrect. (enter_tabpage is called for curtab, which is
not the old tabpage! Plus newtp is not freed)
- Fix checks after creating the tabpage:
- Don't fail if buf wasn't set successfully; the tab page may still be valid
regardless. Set buffer like nvim_open_win, possibly blocking Enter/Leave
events. (except BufWinEnter)
- tp_curwin may not be the initial window opened by win_new_tabpage. Use the
win_T * it returns instead, which is the real first window it allocated,
regardless of autocmd shenanigans.
- Properly check whether tab page was freed; it may have also been freed
before win_set_buf. Plus, it may not be safe to read its handle!
Problem:
"Sorry" in a message (1) is noise, and (2) actually reduces the clarity
of the message because the titlecasing of "Sorry" distracts from the
actually important part of the message.
Solution:
Drop "Sorry" from messages.
Problem: #38316 is a bit aggressive; we need not always leave Terminal mode if
autocmds put us in a different terminal.
Solution: don't skip entering; let terminal_check_focus handle whether we should
immediately leave.
Problem:
`K` in help files may fail in some noisy text. Example:
(`fun(config: vim.lsp.ClientConfig): boolean`)
^cursor
Solution:
- `:help!` (bang, no args) activates DWIM behavior: tries `<cWORD>`,
then trims punctuation until a valid tag is found.
- Set `keywordprg=:help!` by default.
- Does not affect `CTRL-]`, that is still fully "tags" based.
Problem: heap-use-after-free possible when entering Terminal mode if
autocommands close the terminal.
Solution: set the refcount. Skip to the end if we must close the terminal.
Problem: Crash when reading quickfix line (Kaiyu Xie)
Solution: Make sure line is terminated by NUL
closes: vim/vim#19667
Supported by AI
8d13b8244a
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: "win" is allowed in external window configs in some cases. External
window converted to normal float can't move tabpages in one nvim_win_set_config
call. External window can't be turned into a normal split.
Solution: disallow setting "win" for external windows. Allow external window to
move tabpages, which turns it non-external. Allow external window to be turned
into a (non-external) split.
parse_win_config has more validation issues from not considering the window's
existing config enough (not from this PR). For example, zindex can be set for an
existing split if "split"/"vertical" isn't given, despite intending for that to
be an error. Plus the logic is confusing.
It could do with a refactor at some point...
Problem: more cases where it may not be safe to move a window between tabpages.
Solution: check them.
Rather speculative... I haven't spend much time looking, but I didn't find
existing code that sets these locks to skip checking win_valid. (what I did find
called it anyway, like in win_close) Still, I think it's a good precaution for
what future code might do.
If the fact that nvim_win_set_config *actually* moves windows between tabpages
causes unforeseen issues, "faking" it like ":wincmd T" may be an alternative:
split a new window, close the old one, but instead also block autocmds, copy the
old window's config, and give it its handle?
Problem: converting a split to a floatwin may not remove the last statusline
when needed. (e.g: 'ls' is 1)
Solution: call last_status/win_comp_pos in win_new_float, after win_remove.
Also fix float_pos formatting for screen snapshots so it doesn't give a nil
error for external windows.
Not an issue from this PR.
Problem: only possible to move floats between tabpages if relative=win, which
has the restrictive effect of also anchoring it to the target window.
Solution: allow "win" without "relative" or "split"/"vertical". Only assume
missing "win" is 0 if relative=win is given to maintain that behaviour. (or when
configuring a new window)
Also add an error when attempting to change a split into a float that's in
another tabpage, as this isn't actually supported yet. (until the next commit)
Maybe this could do with some bikeshedding. Unclear if "win" should require
"relative" to be given, like with "row"/"col"; this can be annoying though as
specifying "relative" requires other fields to be given too.
Problem: possible to configure a split as a floatwin with relative=win that is
relative to itself.
Solution: fix the check.
Not caused by this PR; just something I noticed when about to fix the validation
logic.
Problem: when nvim_win_set_config moves a floatwin between tabpages, its grid
may remain if temporarily inside another tabpage. Also, things like tablines
aren't redrawn.
Solution: always remove its grid. Set must_redraw so things are redrawn even if
w_redr_type was already set for the old tabpage.
I don't think it's necessary to do anything extra here when removing the grid:
- win_ui_flush calls ui_call_win_hide anyway, and calling it manually ends up
sending two win_hide events.
- ui_comp_remove_grid safely does nothing if the grid doesn't exist.
- w_pos_changed is set by win_config_float later, if that's needed. I think the
pending_comp_index_update set by ui_comp_remove_grid is enough anyway, at
least for making sure win_ui_flush sends win_hide.
Added test fails with the prior approach of checking `parent_tp != curtab`, but
also `win_tp == curtab`. (which is a better, but still flawed alternative)
The added redrawing here also supersedes setting w_hl_needs_update, and also
redraws stuff like the tabline to pass the new test.
- Factor out logic to keep nvim_win_set_config clean.
- Clean up a few things, remove redundant logic, reflow some lines.
- Add some more comments where appropriate.
- Don't consider negative "win", as that's only relevant for splits.
- Add more test coverage.
- Add news.txt entry.
Problem: nvim_win_set_config can't move floating windows to different tab pages.
Solution: allow it.
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
vim-patch:9.2.0128: Wayland: using _Boolean instead of bool type
vim-patch:9.2.0133: memory leak in netbeans_file_activated()
vim-patch:9.2.0136: memory leak in add_interface_from_super_class()
vim-patch:1429277f0 gitattributes: mark dump files as linguist-generated
vim-patch:9.2.0154: if_lua: runtime error with lua 5.5
vim-patch:9.2.0157: Vim9: concatenation can be improved
vim-patch:9.2.0141: :perl ex commands allowed in restricted mode
vim-patch:9.2.0142: Coverity: Dead code warning
vim-patch:9.2.0146: dictionary lookups can be improved
vim-patch:9.2.0148: Compile error when FEAT_DIFF is not defined
vim-patch:9.2.0156: perleval() and rubyeval() ignore security settings
Problem: concatenating strings is slow
Solution: Use grow_string_tv() to grow the existing string buffer in
place when possible (Yasuhiro Matsumoto).
closes: vim/vim#1964216d421a4d9
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Problem: 'showcmd' buffer is being populated for :norm commands, which
can result in a recursive uv_run() when called from a msg_show
vim.ui_attach callback for a shell message.
Solution: The 'showcmd' buffer is never displayed while executing a
:normal command so prevent unnecessary work, avoiding the crash.
Problem: The floating preview window (e.g. completion info)
has mouse=false, so scroll wheel events pass right through it.
Solution: Set mouse=true on the preview float so users can
scroll its content with the mouse wheel.
Problem: #38169 used compl_used_match to determine the CompleteDone
reason, but this fires too broadly, it also changes the reason to
"accept" when the popup was shown and the user dismissed it with <Esc>
or <Space>, breaking snippet completion with autocomplete.
Solution: Instead of checking compl_used_match in, check whether the pum
was never shown (compl_match_array == NULL) in ins_compl_stop().
When a match was inserted but the pum never displayed,
set the completed word so CompleteDone fires with reason "accept".
This keeps the "discard" reason intact when the user dismisses a visible
pum without confirming.
Problem: nvim_parse_cmd rejects valid commands like `:1` (range-only)
or `aboveleft` (modifier-only).
Solution: allow empty command when range or modifiers exist, and handle
execution using existing range command logic.
Problem: blob: concatenation can be improved
Solution: Use ga_grow() to allocate space once and mch_memmove() to copy
the blob data as a single block and fall back to the previous
byte by byte append (Yasuhiro Matsumoto).
closes: vim/vim#1964567deae3b77
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Problem:
When `pum_above` is set, the info window uses `anchor=SW`. Updating the
info window height during `CompleteChanged` causes its top edge to shift,
so it no longer aligns with the top of the pum.
Solution:
Use `NW` as the anchor even when `pum_above` is true so the info window
remains aligned with `pum_row`.
Problem:
If NVIM_LOG_FILE, or the default fallback, is inaccessible (e.g.
directory is owned by root), users get confused.
Solution:
Show a warning when $NVIM_LOG_FILE or $XDG_STATE_HOME are inaccessible.
Also fix a latent memory leak: `os_mkdir_recurse` returns a uv error
code (int), but it was stored as `bool`, causing `os_strerror` to
receive an invalid error code and leak memory.
See: https://docs.libuv.org/en/v1.x/errors.html#c.uv_strerror
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Problem: GUIFG, GUIBG, GUISP handling in do_highlight() is basically
the same code copy-pasted three times.
Solution: Pull the shared logic into a small set_gui_color() helper.
Problem: The GUIFG/GUIBG/GUISP handlers compare sg_rgb_{fg,bg,sp}
(RgbValue) against old_idx (color table index) instead of comparing
sg_rgb_{fg,bg,sp}_idx against old_idx, making did_change unreliable.
Solution: Use the _idx field for the index comparison and add the
missing sg_rgb_sp_idx assignment.
Problem: Reading large files is slow because UTF-8 validation and
newline scanning are performed byte-by-byte. Initial file
loading also triggers listener and channel processing.
Solution: Use memchr() for SIMD-optimized newline scanning, implement
word-at-a-time ASCII skipping during UTF-8 validation using a
bitmask, skip listener/netbeans/channel notifications
when the ML_APPEND_NEW flag is set during readfile()
(Yasuhiro Matsumoto).
closes: vim/vim#196122ca96b09d7
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Co-authored-by: NRK <nrk@disroot.org>
Problem: Using a composing character as the end of a range inside a
collection may corrupt the NFA postfix stack
(Nathan Mills, after v9.1.0011)
Solution: When a character is used as the endpoint of a range, do not emit
its composing characters separately. Range handling only uses
the base codepoint.
supported by AI
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-9phh-423r-778r36d6e87542
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem:
When stopping a PTY process on Windows, the exit code indicates that the
process is stopped by SIGTERM even when closing all streams is enough to
terminate the process. This is inconsistent with other platforms.
Solution:
Set exit_signal to SIGHUP instead of SIGTERM when using SIGHUP.
Problem:
Cross-compilation issues encountered when building Neovim for WASM.
When cross-compiling, three issues occur:
1. `-Wl,--no-undefined` — not supported by `wasm-ld`
2. `-lutil` — not available in the Emscripten sysroot
3. Doc generation fails because CMake tries to execute `$<TARGET_FILE:nvim_bin>` on the host machine, which fails because the binary is not native to the host. It fails with `/bin/sh: nvim.js: Permission denied`
Solution:
The fix includes skipping `-Wl,--no-undefined` and `-lutil` with `NOT CMAKE_CROSSCOMPILING` and adding `NVIM_HOST_PRG` variable to `runtime/CMakeLists.txt` so when cross-compiling, it uses a host native nvim binary for doc generation instead of using the cross-compiled target.