summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/terminal/buffer_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-15refactor: update usages of deprecated "buffer" param #39089Justin M. Keyes1
2026-03-21test(terminal/buffer_spec): increase timeout waiting for REP (#38398)zeertzjq1
On Windows, 10000 milliseconds is sometimes not enough for 20000 lines to be printed. Add 1 millisecond timeout for each printed line.
2026-03-19fix(terminal): don't poll for output during scrollback refresh (#38365)zeertzjq1
Problem: If buffer update callbacks poll for uv events during terminal scrollback refresh, new output from PTY process may lead to incorrect scrollback. Solution: Don't poll for output to the same terminal as the one being refreshed.
2026-03-16fix(terminal): don't always leave if enter autocmds delete buffer #38324Sean Dewar1
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.
2026-03-15fix(terminal): heap UAF from autocmds when entering #38316Sean Dewar1
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.
2026-03-12docs: use "ev" convention in event-handlersJustin M. Keyes1
Problem: In autocmd examples, using "args" as the event-object name is vague and may be confused with a user-command. Solution: Use "ev" as the conventional event-object name.
2026-03-11fix(terminal): free the "[Process exited]" msg extmark #38246Ayaan1
Problem: Since the "[Process exited]" msg is no longer part of buffer contents, `jobstart`'s reuse of unmodified finished terminal buffers does not clear the msg. Solution: Delete the extmark if `term` is already closed.
2026-03-10feat(terminal): surface exit code via virttext + nvim_get_chan_info #37987Ayaan1
Problem: When a terminal process exits, "[Process Exited]" text is added to the buffer contents. Solution: - Return `exitcode` field from `nvim_get_chan_info`. - Show it in the default 'statusline'. - Show exitcode as virtual text in the terminal buffer.
2026-02-26test: remove remaining use of feed_command() in terminal/ (#38069)zeertzjq1
Also deduplicate screen lines in some other tests.
2026-02-24refactor(test): avoid deprecated functions #37017glepnir1
Problem: Tests are using some deprecated functions. Solution: Replace with command, pcall_err, etc.
2026-02-19test: fix flaky tests in terminal/{buffer,channel}_spec.lua (#37966)zeertzjq1
In buffer_spec.lua, wait for a bit more than the refresh delay. In channel_spec.lua, retry sending lines on Windows.
2026-02-15refactor(terminal): don't put cursor at bottom-left in Normal mode (#37873)zeertzjq1
When the terminal process is suspended, putting cursor at bottom-left hints that pressing a key will change the suspended state. However, when returning to Normal mode, the user is more likely to interact with the actual terminal output (e.g. copying it), so it's better to put cursor at the old position which should be closer to the output. Also, using is_focused() to check for mode is confusing. Just check `State & MODE_TERMINAL` instead.
2026-02-14fix(terminal): resuming doesn't work with command in fish (#37857)zeertzjq1
Problem: Resuming terminal process doesn't work with command in fish. Solution: Send SIGCONT to the entire process group. Use killpg() like what bash and zsh do on `fg`: https://cgit.git.savannah.gnu.org/cgit/bash.git/tree/jobs.c?id=637f5c8696a6adc9b4519f1cd74aa78492266b7f#n3928 https://sourceforge.net/p/zsh/code/ci/77045ef899e53b9598bebc5a41db93a548a40ca6/tree/Src/jobs.c#l2674 https://sourceforge.net/p/zsh/code/ci/77045ef899e53b9598bebc5a41db93a548a40ca6/tree/Src/signals.c#l538 Install fish on CI to test this.
2026-02-14fix(terminal): missing refresh with partial mappings (#37839)zeertzjq1
Problem: Terminal buffers are not refreshed when processing keys that trigger partial mappings. Solution: Process due terminal refreshes before redrawing.
2026-02-13feat(terminal): detect suspended PTY process (#37845)zeertzjq1
Problem: Terminal doesn't detect if the PTY process is suspended or offer a convenient way for the user to resume the process. Solution: Detect suspended PTY process on SIGCHLD and show virtual text "[Process suspended]" at the bottom-left. Resume the process when the user presses a key.
2026-02-09fix(terminal): set b_locked when setting &buftype (#37787)Sean Dewar1
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.
2026-02-05fix(terminal): handle split composing chars at right edge (#37694)zeertzjq1
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.
2026-02-04fix(terminal): also don't propagate $COLORTERM on Windows (#37699)zeertzjq1
The same reason in #26440 applies to Windows as well.
2026-02-03ci(test): bump Windows runners to windows-2025 and unskip tests (#37666)zeertzjq1
Bumping to windows-2025 seems to fix at least one case of spaces having wrong attributes in TUI tests, which allow unskipping dozens of tests.
2026-01-29test(terminal): status is -1 in TermClose if buffer is deleted (#37609)zeertzjq1
2026-01-28fix(terminal): wrong scrollback with BufFile* autocommand (#37601)zeertzjq1
Problem: Wrong terminal scrollback if BufFile* autocommand drains PTY output but doesn't process the pending refresh. Solution: Refresh scrollback before refreshing screen in terminal_open() if scrollback has been allocated.
2026-01-28fix(terminal): losing output if BufFile* poll for events (#37580)zeertzjq1
Problem: Terminal loses output if a BufFilePre or BufFilePost autocmd polls for events. Solution: Rename the buffer after allocating the terminal instance. Also fix buffer getting wrong name if BufFilePre uses NameBuff.
2026-01-27fix(terminal): don't allow b:term_title watcher to delete bufferzeertzjq1
2026-01-27fix(terminal): losing scrollback when TermOpen polls for events (#37573)zeertzjq1
Problem: When TermOpen polls for enough events to use the scrollback buffer, scrollback is lost until the next terminal refresh. Solution: Allocate the scrollback buffer when it's needed.
2026-01-22fix(terminal): <Ignore> should be no-op (#37494)zeertzjq1
2026-01-21fix(terminal): restore options properly when switching buffer (#37485)zeertzjq1
2026-01-15fix(process): don't limit PTY master remaining data sizezeertzjq1
2026-01-10fix(terminal): :edit should respect 'bufhidden' with exited job (#37301)zeertzjq1
2026-01-08vim-patch:9.1.2066: :wqall! doesn't close a terminal like :qall! does (#37314)zeertzjq1
Problem: :wqall! doesn't close a terminal buffer like :qall! does (after 8.0.1525). Solution: Check eap->forceit (zeertzjq). Ref: https://github.com/vim/vim/issues/2654#issuecomment-366803932 related: vim/vim#2654 related: neovim/neovim#14061 closes: vim/vim#19129 https://github.com/vim/vim/commit/d8558fdf4f2758163218289637e82c3ae2d617ec
2026-01-08test(terminal/buffer_spec): fix flaky test (#37299)zeertzjq1
It turns out that uv_write() doesn't queue the write if there are no pending writes, so vim.uv.run() isn't needed to reproduce the crash.
2026-01-06fix(buffer): don't reuse 1-line terminal buffer (#37261)zeertzjq1
Problem: :edit and :enew may reuse a 1-line terminal buffer, causing the new buffer to still be a terminal buffer. Solution: Don't reuse a terminal buffer, as it's not reused when it has more than 1 line. After this change close_buffer() is the only place where buf_freeall() can be called on a terminal buffer, so move the buf_close_terminal() call into buf_freeall() to save some code. Furthermore, closing the terminal in buf_freeall() is probably more correct anyway, as it is "things allocated for a buffer that are related to the file". Also, remove the useless check for on_detach callbacks deleting buffer. Even if b_locked fails to prevent that, the crash will happen at the end of buf_updates_unload() first. On the other hand, many other call sites of buf_updates_unload() and other buffer_updates_* functions don't set b_locked, which may be a problem as well...
2026-01-05fix(terminal): avoid multiple terminals writing to same buffer (#37219)zeertzjq1
Problem: Calling termopen() or nvim_open_term() on a buffer with an existing terminal leads to two terminals writing to the same buffer if the terminal job is still running, or memory leak if the terminal job has exited. Solution: Close the terminal if the terminal job has exited, otherwise report an error. For nvim_open_term() also don't write a closed terminal's buffer content to the PTY.
2026-01-05fix(terminal): crash with race between buffer close and OSC 2 (#37225)zeertzjq1
Problem: Crash when a terminal receives OSC 2 just after closing its buffer but before terminal job exits. Solution: Remove FUNC_ATTR_NONNULL_ALL from buf_set_term_title() and check for NULL.
2026-01-04fix(terminal): handle closing terminal with pending TermRequest (#37227)zeertzjq1
Problem: Destroying a terminal with pending TermRequest leads to heap-use-after-free when processing TermRequest afterwards. Solution: Store the buffer handle instead of the Terminal pointer in the pending TermRequest event, and don't emit TermRequest if the terminal is already closed.
2025-10-24fix(terminal): wrong row in TermRequest with full scrollback (#36298)zeertzjq1
Problem: Wrong row in TermRequest with full scrollback. Solution: Subtract by the number of lines deleted from scrollback.
2025-08-26fix(terminal): patch various autocommand-related holesSean Dewar1
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-08-26fix(terminal): update winopts and focus when switching terminalsSean Dewar1
Problem: window options and terminal focus notifications not updated when switching terminals without leaving terminal mode. Solution: update them.
2025-07-16test(tui_spec): flakiness, global highlight definitions #34958luukvbaal1
2025-05-09fix(terminal): check size when switching buffersSean Dewar1
Problem: terminal not always resized when switching to its buffer. Solution: add missing calls to terminal_check_size.
2025-03-08fix(events): always allow some events to be nested (#32706)zeertzjq1
Always allow the following four events to be nested, as they may contain important information, and are triggered on the event loop, which may be processed by a blocking call inside another autocommand. - ChanInfo - ChanOpen - TermRequest - TermResponse There are some other events that are triggered on the event loop, but they are mostly triggered by user actions in a UI client, and therefore not very likely to happen during another autocommand, so leave them unchanged for now.
2025-03-07fix(terminal): avoid rescheduling events onto the same queue (#32755)Gregory Anders1
Problem: When a function like vim.wait() is used, we continuously drain the main event queue until it is empty, never stopping for user input. This means the libuv timer never runs and the terminal never gets refreshed, so emit_termrequest continously reschedules itself onto the same event queue, causing an infinite loop. Solution: Use a separate "pending" event queue, where events that require a terminal refresh are temporarily placed. Drain this queue after a terminal refresh and events are copied back onto the main queue. This prevents infinite loops since the main event queue will always be able to properly drain.
2025-03-05feat(terminal)!: include cursor position in TermRequest event data (#31609)Gregory Anders1
When a plugin registers a TermRequest handler there is currently no way for the handler to know where the terminal's cursor position was when the sequence was received. This is often useful information, e.g. for OSC 133 sequences which are used to annotate shell prompts. Modify the event data for the TermRequest autocommand to be a table instead of just a string. The "sequence" field of the table contains the sequence string and the "cursor" field contains the cursor position when the sequence was received. To maintain consistency between TermRequest and TermResponse (and to future proof the latter), TermResponse's event data is also updated to be a table with a "sequence" field. BREAKING CHANGE: event data for TermRequest and TermResponse is now a table
2025-02-13feat(term): trigger TermRequest for APC (#32407)Till Bungert1
Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-02-02vim-patch:9.1.1068: getchar() can't distinguish between C-I and Tab (#32295)zeertzjq1
Problem: getchar() can't distinguish between C-I and Tab. Solution: Add {opts} to pass extra flags to getchar() and getcharstr(), with "number" and "simplify" keys. related: vim/vim#10603 closes: vim/vim#16554 https://github.com/vim/vim/commit/e0a2ab397fd13a71efec85b017d5d4d62baf7f63 Cherry-pick tv_dict_has_key() from patch 8.2.4683.
2025-01-21feat(terminal): forward X1 and X2 mouse eventszeertzjq1
Ref: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons
2025-01-16feat(terminal): add support for kitty keyboard protocolGregory Anders1
This commit adds basic support for the kitty keyboard protocol to Neovim's builtin terminal. For now only the first mode ("Disambiguate escape codes") is supported.
2025-01-15Merge #32001 from MariaSolOs/consistent-namespacesJustin M. Keyes1
2025-01-14refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano1
2025-01-13fix(getchar): do not simplify keycodes in terminal modebfredl1
The code represents a useful pattern in normal mode where remapping `<tab>` will implicitly also remap `<c-i>` unless you remap that explicitly. This relies on the _unmapped_ behavior being identical which is not true in terminal mode, as vterm can distinguish these keys. Vim seems to entangle this with kitty keyboard mode detection which is irrelevant for us. Conditional fallbacks depending on keyboard mode could be done completely inside `vterm/` without getchar.c getting involved, I would think.
2025-01-09fix(terminal): don't crash on unprintable charsbfredl1
fixes #31897