backport https://github.com/neovim/neovim/pull/36746
Problem:
Currently we fetch a prebuilt xxd.exe from neovim/deps for Windows,
which is not ideal in terms of obviousness, misses updates, and is
clumsy to update.
Solution:
Similar to tee.c (#36363), vendor xxd.c from Vim and build it as part
of the Neovim build process. This makes the source obvious, enables
analyzer checks, and simplifies updates.
Fixes#36664
Co-authored-by: benarcher2691 <ben.archer2691@gmail.com>
Problem:
In scripts/genappimage.sh running on arm64 host, the $ARCH will be set to
'arm64' before calling linuxdeploy, which cause linuxdeploy to generate
an 32bit ELF executable instead 64bit. See the issue for more details.
Solution:
Keep $ARCH unchanged, use $ARCH_OUTPUT in the output file name. On arm64
host, $ARCH_OUTPUT will be converted to 'arm64'.
(cherry picked from commit 4daa8eb5ab)
Problem: apply_autocmds function can free both buf_T and win_T pointers
Solution: instead retain winids for WinResized and WinScrolled
autocmds and use curbuf pointer, which is consistent with other uses
of apply_autocmds function
(cherry picked from commit 0a0c349b6f)
Problem:
When `MANPAGER` is set to something like 'nvim +Man!',
`vim.system({ 'nvim' })` call waits forever for input and times out
after 10 seconds in `system()` and the assert on `stdout` being not
`nil` fails.
Solution:
Set `MANPAGER=cat` when calling `system()`
(cherry picked from commit 87bd16e470)
Initial support for compiling on haiku os. Some deps can be pulled from
haiku repos, some need to be compiled with nvim's dep build system:
cmake -DUSE_BUNDLED_LIBUV=OFF -DUSE_BUNDLED_UNIBILIUM=OFF -DUSE_BUNDLED_LUAJIT=OFF -B .deps ./cmake.deps
make -C .deps
(cherry picked from commit 10c11c4644)
Problem: `extmark_splice()` was being called before `ml_replace()`,
which caused the on_bytes callback to be invoked with the old buffer
text instead of the new text.
Solution: store metadata for each match in a growing array, call
`ml_replace()` once to update the buffer, then call `extmark_splice()`
once per match.
Closes https://github.com/neovim/neovim/issues/36370.
(cherry picked from commit 7da4d6abe2)
Limit the default truncation item to the current recursion range so
nested `nvim_eval_statusline()` calls don't reuse stale `stl_items`
pointers. Add a functional regression that evaluates a Lua statusline
helper which forces truncation to ensure the nested scenario stays
stable.
AI-Assist: OpenAI ChatGPT
Fixes#36616
(cherry picked from commit e9b6474ae7)
Problem:
AUR does not want a web-scale implementation of "tee".
Solution:
- Only install "tee" on Windows.
- The build will still produce `./build/bin/tee` on all platforms, to
have more coverage and avoid special-cases in tests.
(cherry picked from commit e0308dc147)
build(windows): restore "tee" on Windows
Problem:
Neovim no longer ships with a tee binary on Windows, which breaks
functionality for the :grep and :make commands.
nvim --clean
:grep foo or :make
"tee is not recognized as an internal or external command"
Solution:
Include a simple, no-dependency tee.c source file in the src/ directory.
Update CMakeLists.txt to build a tee executable alongside neovim during
the build process, and ensure the tee.exe program appears alongside the
neovim executable in the bin/ directory so that it is accessible for
:grep and :make.
tee.c was obtained from the vim codebase:
https://github.com/vim/vim/blob/master/src/tee/tee.c
And we modified it to fix performance issues.
Testing:
nvim --clean
:grep foo or :make, after setting a file to the makeprg option.
Verify that :grep results and error output from a compiler appear in the message pane.
ref https://github.com/neovim/neovim/issues/32431
fix https://github.com/neovim/neovim/issues/32504
Other tee options:
- [tee-win32](https://github.com/dEajL3kA/tee-win32): MIT. However,
I couldn't get it to build on my machine even after updating its
makefile to call my install of MSVC. It's also super optimized and
uses some processor intrinsics for multithreading.
- [gnu coreutils tee](https://gnuwin32.sourceforge.net/packages/coreutils.htm):
(Windows coreutils contains a tee.c. Last updated 2005. Did not build
immediately on my machine; we'd have to determine which definitions
from elsewhere in coreutils tee.c needs and incorporate them somehow.
- [WinTee](https://github.com/mpderbec/WinTee): Has no license. Last
updated 11 years ago. Relies on Visual Studio to build.
Co-authored-by: friendlyman23 <ams5661@gmail.com>
docs(diagnostic): diagnostic.Opts.Float extend open_floating_preview.Opts #30058
Problem: the opts table also is param of util.open_floating_preview,
vim.diagnostic.Opts.Float missing some fields of open_floating_preview.
Solution: diagnostic.Opts.Float extend util.open_floating_preview.Opts
Fix#29267
Co-authored-by: glepnir <glephunter@gmail.com>
fix(windows): wrong RT_MANIFEST ID in nvim.rc #36406
Problem:
Starting Nvim on MinGW fails:
https://github.com/msys2/MINGW-packages/issues/25140
Unknown system error -1:"C:\msys64\ucrt64\bin\nvim.exe"Failed to start Nvim server!
Solution:
On Windows, the main application manifest should use resource ID 1 (RT_MANIFEST).
Update `nvim.rc` to use `1 RT_MANIFEST nvim.manifest` instead of `2`,
ensuring the manifest is correctly embedded and recognized by the system.
ID = 1 is for executable files (.exe)
ID = 2 is for DLLs (/DLL)
From MSVC docs: "Use a value of 2 for a DLL to enable it to specify private dependencies."
https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest
(cherry picked from commit 2c04ae9fcc)
Co-authored-by: SquallATF <squallatf@gmail.com>
backport #36407
This reverts 2495e7e. That past change meant that we would modify the
buffer contents of a tmux session if it exists, even if the current Nvim
process wasn't running inside of it. Depending on the tmux
configuration, this could even affect the clipboard of an actually
attached tmux client, since tmux itself uses OSC 52 to forward buffer
writes to attached clients.
While autodetection is usually a trade-off and can rarely make everybody
happy, this behavior goes counter the principle of least surprise. If
really desired, it can be brought back by explicit configuration.
Co-authored-by: Daniel Danner <dnnr@users.noreply.github.com>
Workaround (not a fix) for #27196 and for #33067
Asserts are meant to apply to debug builds but not release
builds for users. However the intermediate RelWithDebInfo
build type is quite often used by end users, so we might
want to disable certain problematic asserts there, while
still preserving them in Debug mode for CI.
Since NeoVim is installed in `Program Files` directory by default, path
to tutor filename must be quoted before passing to `:drop`.
(cherry picked from commit 4143bcbd37)
`:trust` command calculated SHA-256 on file content reading it as a
text. While it doesn't matter on Unices, on Windows hash was calculated
incorectly. SHA-256 for buffer content was calculated fine though.
After this fix hashes in `%LOCALAPPDATA%/nvim-data/trust` are the same
as in output of `sha256sum -t`.
(cherry picked from commit b15b22fc73)
Following is a list of commits (fixes/features only) in this release.
See `:help news` in Nvim for release notes.
FEATURES
--------------------------------------------------------------------------------
- 693772100e help: gx opens help tag in web browser (#35784)
- f9cad88d5a vimscript: log function name in "fast" message #32616
PERFORMANCE
--------------------------------------------------------------------------------
- 4c8486e1f2 scheduler priority clamping on macOS #35488
- 0f6a180bcc api: reduce redundant `win_find_tabpage` calls (#35643)
FIXES
--------------------------------------------------------------------------------
- 4e4428dee8 vim.lsp.omnifunc should not throw away other items #35346
- f2fb46ef9e api: nvim_open_win default to half-size for splits (#36088)
- 479bb9cbab api: nvim_open_win respects requested split window size (#35601)
- 5aa6257e8c api: win_set_config error message for splitting from a float #35650
- 66b8018b06 channel: closing socket with pending writes leaks memory (#36400)
- 3237f634fa cjson: fix `strbuf_set_length` incorrectness #35565
- 95cc67538b clipboard: avoid using stale register width (#36178)
- d31953d532 diagnostics: extend conversion support from/to quickfix format (#34006)
- 7304fc275e excmd: :trust executed even when inside false condition (#36032)
- 0e1c83fae2 filetype: handle invalid `bufnr` in _getlines(), _getline() #36272
- 86b2c0f201 float: crash from nasty :fclose autocmds (#36137)
- d8a7c86e73 health: errors in :checkhealth with pyenv-virtualenv #35865
- 8e00534b1e health: hard fail on invalid "python-*" bin #35382
- 2668a46902 lsp: "attempt to index nil config" #36189
- 21540d21ca lsp: _get_workspace_folders does not handle root_dir() function (#36141)
- 14e74d98fd lsp: misleading logs in non-applicable filetypes #35749
- a7eb110098 lsp: noisy log message when enabling server without config #36264
- eb4837206a lsp: restore Client:stop() force-stopping behavior (#35800)
- 556d8d0002 lsp: treat 2-triggers-at-once as "last char wins" #35435
- 7b1ac2080d lua: don't leak handle when vim._watch.watch() fails (#35768)
- c84ba83cf1 options: increase t_Co buffer size (#35859)
- 7aea000343 paste: don't use :echo immediately before :redraw (#35773)
- 47f6f21998 plines: count 'showbreak' in EOL inline virt_text in line size (#35921)
- 4338eea269 rpc: handle more cases when identifying loopback #36100
- d399ed310e socket: avoid stack-use-after-return after timeout (#36405)
- 4cc060bf44 statusline: redraw if Visual selection other end changes (#36281)
- 7f5427b857 terminal: add various missing redraws
- d78d5cf1aa terminal: adjust marks when deleting scrollback lines (#36294)
- f3f6705075 terminal: avoid events messing up topline of focused terminal
- 8c5bc4920a terminal: avoid tailed cursor in focused terminal in events
- 934d28558d terminal: check size when creating new tabpage
- e67fec1541 terminal: deleting from wrong buffer (#36289)
- e4db5edb8a terminal: don't trigger TextChangedT for unrelated redraws
- 854b319060 terminal: handle OSC 8 split into multiple fragments
- a6d8f40b64 terminal: keep last cursor if it's on the last row
- 46d68e5290 terminal: patch various autocommand-related holes
- 5ee9e3f258 terminal: possibly wrong wrow/wcol in active terminal
- b21ec366b9 terminal: remove condition that buf is curbuf (#33721)
- 2eea65fe68 terminal: update winopts and focus when switching terminals
- 169dc60a44 terminal: wrong row in TermRequest with full scrollback (#36298)
- 8f05fdbfb3 tests: ignore vector math types
- 924a8e4238 tui: don't wait for DA1 response when stdin is closed (#35745)
- 07184aa973 tui: handle sequence larger than entire buffer
- 1c8805e3b2 vim.json: fix truncation of decoded numbers outside lua_Integer's range #35702
- 8c311386c3 window: don't add a hsep when out of room if global stl is off
VIM PATCHES
--------------------------------------------------------------------------------
- dd79bc8360 014c731: runtime(doc): make :h virtcol() more accurate (#35976)
- c2a3838ab2 8.1.0636: line2byte() gives wrong values with text properties
- a0dac399d0 8.1.1681: insert stray "{" when listener gets buffer line
- d573ffcfc7 8.1.1700: listener callback called for the wrong buffer
- 7159a0192b 8.1.1711: listener callback called at the wrong moment
- b6dd8bbca0 8.1.2008: error for invalid range when using listener and undo
- 03f9df8117 8.2.0115: byte2line() does not work correctly with text properties
- d1a0d0889b 8.2.0844: text properties crossing lines not handled correctly
- 9b5545103e 8.2.0853: ml_delete() often called with FALSE argument
- c8912d7329 8.2.3348: line2byte() returns wrong value after adding textprop
- b0ed4a3cb8 8.2.3795: too many #ifdefs
- e4bbe09dcc 8.2.4379: an empty change is reported to a listener
- 5c6ea43da8 80981e1: runtime(doc): mention 'findfunc' at :h :find (#35697)
- 8634a46165 9.1.0689: [security]: buffer-overflow in do_search() with 'rightleft'
- a839200c0a 9.1.0695: tests: test_crash leaves Untitled file around
- 61aab4cfe0 9.1.0698: tests: "Untitled" file not removed when running Test_crash1_3 alone
- 85e4503f18 9.1.1754: :helptags doesn't skip examples with syntax
- 77fe01f200 9.1.1773: Crash in BufLeave after BufUnload closes other windows (#35830)
- 7e724dfa2f 9.1.1780: mbyte contains overlapping list of utf_classes table (#35869)
- 4db62d96bc 9.1.1798: Wrong display with 'sms' and long wrapped virt text at EOL (#35930)
- 9c09983068 9.1.1802: 'nowrap' in a modeline may hide malicious code (#35946)
- 67688ab616 9.1.1807: :set doesn't clear local insecure flag like :setlocal does
- 6dda8e9572 9.1.1808: Option insecure flags not copied when splitting window
- ac48d9c3c9 9.1.1823: diff: w_topline may be invalidated (#36018)
- e1fe0ed2df 9.1.1831: stray vseps in right-most 'winfixwidth' window
- d21c23b8c9 9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab
- aab8134f87 9.1.1839: Window may have wrong height if resized from another tabpage (#36093)
- ad172eb762 9.1.1858: v:register not reset after Visual mode command (#36215)
- a4319015ee 9.1.1868: v:register is wrong in v_: command (#36238)
- 8928ede8af 9.1.1870: :Tutor may not work as expected (#36343)
- 1b27d8f428 9.1.1871: Wrong 'showcmd' in the cmdwin (#36320)
- a2d4a0fda9 9.1.1885: Wrong restored cursor pos when re-entering buffer after changes
- 7790dca2eb 9.1.1891: g<End> does not move to last non-blank in visual mode (#36354)
- 88ff561dcc 9.1.1893: ICCF charity will dissolve (#36427)
- 19d58cb2cc a0f37db: runtime(doc): use a single pattern in :h 'incsearch' example (#35721)
- 8ed1ef1377 partial:9.0.0323: using common name in tests leads to flaky tests
CI
--------------------------------------------------------------------------------
- e415fae42e Windows arm64 packages #35345
Problem: In visual mode, g<End> does not move to the last non-blank
character when the end of a line is on the same line as the
cursor (after v9.0.1753)
Solution: Move the cursor back by one position if it lands after the
line (varsidry)
fixes: vim/vim#18657closes: vim/vim#18658adc85151f3
(cherry picked from commit b92b95e2c2)
Problem:
In socket_connect(), if connecting to the given TCP address times out,
libuv is still trying to connect to the address, and connect_cb may be
called when running the libuv event loop after the `status` variable
referenced by `req.data` goes out of scope.
Solution:
Close the uv_tcp_t handle and wait for connect_cb to be called before
retrying or failing in socket_connect(). This also avoid leaking libuv
handles.
The tests added here only check that the non-timeout case still works,
as checking the timeout case is very hard without modifications to the
code. Removing the first LOOP_PROCESS_EVENT_UNTIL() in socket_connect()
(the one with the timeout) is a way to check that manually.
Also add a comment about the cause of the ASAN error in #34586.
Problem: Closing socket with pending writes leaks memory.
Analysis: When calling rstream_may_close() on an RStream with pending
writes, it waits for write_cb() to call stream_close_handle(),
which closes it as if it's a WStream and doesn't free the
RStream's buffer.
Solution: Ensure that an RStream's buffer is freed when it's closed.
Problem: Wrong restored cursor position when re-entering a buffer
previously viewed in a window after making changes to the same
buffer in another window.
Solution: Adjust per-window "last cursor" positions on buffer changes.
(zeertzjq)
closes: vim/vim#18655b2e6b328da
Problem: TextChangedT fires depending on whether Nvim needs to update_screen
while in terminal mode. This makes little sense as redraws can be completely
unrelated to the terminal. Also, TextChanged could be fired from changes in
terminal mode after returning to normal mode.
Solution: trigger it when b:changedtick changes, like other such events. Happens
when invalid cells are refreshed, though is no longer affected by cursor
changes. Don't fire TextChanged from changes in terminal mode after leaving.
Unlike the other TextChanged* events, I've elected to not have it be influenced
by typeahead. Plus, unlike when leaving insert mode when no TextChangedI events
are defined, I don't trigger TextChanged when returning to normal mode from
changes in terminal mode (is that a Vim bug?)
Curiously, Vim's TextChangedT is different; it's tied to its terminal cursor
redraws, which triggers pretty eagerly (but is unaffected by unrelated redraws)
- usually *twice* when data is sent to the terminal (regardless of whether it
causes any visible changes, like incomplete escape codes; wasn't true for Nvim).
Not clear to me how this event was actually intended to work, but this seems to
make the most sense to me.
Problem: w_wrow/col calculation in terminal_check_cursor is wrong when the
terminal is smaller than the window. Common when there's a larger window open
with the same terminal, or just after a resize (as refresh_size is deferred).
Solution: don't calculate it; validate_cursor will correct it later if it's
out-of-date.
Note that the toplines set for the terminal (also before this PR) assume
'nowrap' (which is set by default for terminal windows), and that no weird stuff
like filler lines are around. That means, for example, it's possible for the
cursor to be moved off-screen if there's wrapped lines. If this happens, it's
likely update_topline will move the cursor back on screen via validate_cursor or
similar, but maybe this should be handled more elegantly in the future?
Problem: autocommands can cause various problems in terminal mode, which can
lead to crashes, for example.
Solution: fix found issues. Move some checks to terminal_check and guard against
autocommands messing with things. Trigger TermEnter/Leave after terminal mode
has changed/restored most state. Wipeout the correct buffer if TermLeave
switches buffers and fix a UAF if it or WinScrolled/Resized frees the terminal
prematurely.
These changes also allow us to remove the buffer restrictions on TextChangedT;
they were inadequate in stopping some issues, and WinScrolled/Resized was
lacking them anyway.
Problem: when creating a new tabpage with a terminal window, terminal size is
not updated if there is no statusline.
Solution: do not rely on last_status to implicitly call terminal_check_size as a
side effect of making room for a statusline; call it directly.
Problem: topline of a focused terminal window may not tail to terminal output if
events scroll the window.
Solution: set the topline in terminal_check_cursor.
Problem: missing redraws when restoring saved cursorline/column, plus missing
statusline and mode redraws when not updating the screen in terminal mode.
Solution: schedule the redraws in a similar manner to other modes and remove
some now unnecessary redrawing logic. Redraw if cursorline-related options
change from entering terminal mode. This fixes test failures in later commits.
WTF: TextChangedT triggers based on must_redraw, which is... fun...? Try to
preserve its behaviour as much as we can for now.
Problem: in terminal mode, adjust_topline moves curwin's cursor to the last row
so set_topline tails the non-scrollback area. This may result in the observed
cursor position remaining tailed in events within the focused terminal, rather
than reflecting the actual cursor position.
Solution: use the focused terminal's actual cursor position immediately, rather
than relying on the next terminal_check_cursor call in terminal_check to set it.
Note: Maybe also possible for terminal mode cursor position to be stale
(reporting the normal mode position) when switching buffers in events to another
terminal until the next terminal_check call? (or until refresh_terminal is
called for it) Maybe not worth fixing that, though.