Commit Graph

32702 Commits

Author SHA1 Message Date
Justin M. Keyes
1f93acc293 backport: build(windows): vendor xxd.c (#36755)
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>
2025-11-30 05:33:55 +00:00
Siwen Yu
79b67ce331 fix(appimage): wrong $ARCH used by linuxdeploy #36712
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)
2025-11-27 18:28:21 +00:00
Kent Sibilev
656ff4c438 fix(events): crash on WinScrolled #35995
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)
2025-11-26 15:17:02 +00:00
Muhammad Saheed
5143419e22 fix(man.lua): :Man slow/hangs if MANPAGER is set #36689
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)
2025-11-26 14:45:37 +00:00
User0
d0ed06dcea build: haiku os support #36639
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)
2025-11-26 14:39:22 +00:00
zeertzjq
9978b1b29e Merge pull request #36701 from zeertzjq/backport
docs: misc
2025-11-26 22:07:57 +08:00
Justin M. Keyes
0bc2381b6b docs: misc
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: glepnir <glephunter@gmail.com>
2025-11-26 21:47:10 +08:00
Riccardo Mazzarini
da825e5541 fix(api): on_bytes gets stale data on :substitute #36487
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)
2025-11-21 06:15:38 +00:00
Lewis Russell
53090ab6a8 fix(statusline): scope truncation bookkeeping
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)
2025-11-20 12:10:46 +00:00
Justin M. Keyes
63c5a101af fix(install): only install "tee" on Windows #36629
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)
2025-11-20 05:37:32 +00:00
Justin M. Keyes
a94647bb08 backport: build(windows): restore "tee" on Windows #36627
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>
2025-11-19 17:03:42 -08:00
Justin M. Keyes
2794d349ad docs(diagnostic): diagnostic.Opts.Float extend open_floating_preview.… (#36612)
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>
2025-11-18 22:05:29 -08:00
neovim-backports[bot]
fac7c10eb8 fix(windows): set manifest resource ID to 1 in nvim.rc for MinGW (#36611)
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>
2025-11-18 21:56:26 -08:00
Justin M. Keyes
0358f37e3d backport: fix(clipboard): use tmux only in a tmux session (#36603)
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>
2025-11-18 18:37:41 -08:00
neovim-backports[bot]
6a507bad18 fix(vim.fs): abspath(".") returns "/…/." (#36584)
fix(vim.fs): abspath(".") returns "/…/." #36583

(cherry picked from commit 1f9d9cb2e5)

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-11-17 08:49:19 -08:00
Cameron Ring
d974c684da fix(vim.fs): root() should always return absolute path #36466
(cherry picked from commit f11f8546e7)
2025-11-17 06:09:23 +00:00
zeertzjq
a6bc5780ac test(api/server_requests_spec): fix flaky test (again) (#36570)
Use a fast API, as a deferred API request may be aborted by EOF.

(cherry picked from commit c924d68021)
2025-11-16 10:38:51 +00:00
Justin M. Keyes
c12cb0db42 Merge #36565 backports 2025-11-15 11:56:05 -08:00
Justin M. Keyes
9785552f68 ci: disable wasmtime build
backport 22fedc09b0
2025-11-15 14:36:40 -05:00
bfredl
16ca7ceaed fix(build): disable problematic marktree assert in RelWithDebInfo builds
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.
2025-11-15 14:31:43 -05:00
zeertzjq
85404d18fe vim-patch:eb732ed: runtime(doc): Wrap overlength lines in uganda.txt (#36550)
Wrap overlength lines and normalise URL indentation.

closes: vim/vim#18737

eb732ed26d

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
(cherry picked from commit 1a5f0ba201)
2025-11-14 00:21:00 +00:00
Andrey Starodubtsev
d997c8e344 fix(tutor): escape tutor filename #36539
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)
2025-11-13 03:55:23 +00:00
Andrey Starodubtsev
076f7994be fix(trust): :trust command on Windows #36509
`: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)
2025-11-12 06:41:42 +00:00
Maria Solano
890c257194 fix(lsp): check nvim.lsp.enable before doautoall #36518
(cherry picked from commit 653871da1b)
2025-11-12 06:40:09 +00:00
skewb1k
ae25f6942e revert: fix: vim.lsp.omnifunc should not throw away other items
revert: fix: vim.lsp.omnifunc should not throw away other items #35346

This reverts commit 4e4428dee8.
2025-11-10 11:10:41 +08:00
Maria Solano
b92e92b20d feat(lsp): support auto-force escalation in client stop #36430
(cherry picked from commit 02cd564896)
2025-11-02 09:01:41 -08:00
Justin M. Keyes
e0fdfd3d4b fix(scripts): release.sh 2025-11-02 11:55:50 -05:00
Justin M. Keyes
9fe0edfe2f version bump 2025-11-02 11:17:43 -05:00
Justin M. Keyes
9fa7c0a046 NVIM v0.11.5
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
stable v0.11.5
2025-11-02 11:14:24 -05:00
zeertzjq
f8a3cbc194 Merge pull request #36428 from zeertzjq/backport
vim-patch:9.1.1893: ICCF charity will dissolve (#36427)
2025-11-02 08:58:45 +08:00
zeertzjq
88ff561dcc vim-patch:9.1.1893: ICCF charity will dissolve (#36427)
Problem:  ICCF charity will dissolve
Solution: Update references to Kuwasha

Since the ICCF[1] will be dissolved and handing over to the Kuwasha charity
to continue supporting the Kibaale Children Center in Uganda, update the
uganda.txt help file.

[1]: https://groups.google.com/g/vim_announce/c/pUNbNXBLbKw/m/-zFUd4JjAQAJ

fixes: vim/vim#18584
closes: vim/vim#18667

0405665638

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-11-02 08:30:42 +08:00
varsidry
7790dca2eb vim-patch:9.1.1891: g<End> does not move to last non-blank in visual mode (#36354)
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#18657
closes: vim/vim#18658

adc85151f3
(cherry picked from commit b92b95e2c2)
2025-11-01 02:08:42 +00:00
zeertzjq
8b95dd2630 Merge pull request #36418 from zeertzjq/backport
fix(socket): avoid stack-use-after-return after timeout (#36405)
2025-11-01 09:00:47 +08:00
zeertzjq
d399ed310e fix(socket): avoid stack-use-after-return after timeout (#36405)
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.
2025-11-01 08:25:02 +08:00
zeertzjq
b74f74ba20 test(api/server_requests_spec): fix flaky test (#36410)
Wait for the notification to be processed.

(cherry picked from commit 2b83237b0f)
2025-10-31 14:45:36 +00:00
zeertzjq
66b8018b06 fix(channel): closing socket with pending writes leaks memory (#36400)
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.
2025-10-31 01:49:21 +00:00
zeertzjq
72c13ef84e Merge pull request #36379 from zeertzjq/backport
Backport terminal fixes
2025-10-29 13:43:40 +08:00
zeertzjq
a6d8f40b64 fix(terminal): keep last cursor if it's on the last row 2025-10-29 13:08:22 +08:00
zeertzjq
a2d4a0fda9 vim-patch:9.1.1885: Wrong restored cursor pos when re-entering buffer after changes
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#18655

b2e6b328da
2025-10-29 13:08:22 +08:00
Sean Dewar
e4db5edb8a fix(terminal): don't trigger TextChangedT for unrelated redraws
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.
2025-10-29 13:08:22 +08:00
Sean Dewar
5ee9e3f258 fix(terminal): possibly wrong wrow/wcol in active terminal
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?
2025-10-29 13:08:22 +08:00
Sean Dewar
46d68e5290 fix(terminal): patch various autocommand-related holes
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.
2025-10-29 13:08:22 +08:00
Sean Dewar
2eea65fe68 fix(terminal): update winopts and focus when switching terminals
Problem: window options and terminal focus notifications not updated when
switching terminals without leaving terminal mode.

Solution: update them.
2025-10-29 13:08:22 +08:00
Sean Dewar
934d28558d fix(terminal): check size when creating new tabpage
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.
2025-10-29 13:08:22 +08:00
Sean Dewar
f3f6705075 fix(terminal): avoid events messing up topline of focused terminal
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.
2025-10-29 13:08:22 +08:00
Sean Dewar
7f5427b857 fix(terminal): add various missing redraws
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.
2025-10-29 13:08:22 +08:00
Sean Dewar
8c5bc4920a fix(terminal): avoid tailed cursor in focused terminal in events
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.
2025-10-29 13:08:22 +08:00
zeertzjq
98dfd25c8b test(ex_terminal_spec): fix flakiness (#36347)
(cherry picked from commit db35dd6734)
2025-10-27 03:30:22 +00:00
zeertzjq
8928ede8af vim-patch:9.1.1870: :Tutor may not work as expected (#36343)
Problem:  :Tutor may not work as expected
Solution: set buftype=nowrite instead of nofile
          (Phạm Bình An)

closes: vim/vim#18613

9978bb77c6

Co-authored-by: Phạm Bình An <phambinhanctb2004@gmail.com>
(cherry picked from commit fb6fd17f26)
2025-10-27 01:52:29 +00:00
zeertzjq
1b27d8f428 vim-patch:9.1.1871: Wrong 'showcmd' in the cmdwin (#36320)
Problem:  Wrong 'showcmd' in the command-line window.
Solution: Clear 'showcmd' when entering cmdwin (zeertzjq).

related: neovim/neovim#36271
closes: vim/vim#18616

826326f13b
(cherry picked from commit 5db3544991)
2025-10-25 14:45:41 +00:00