aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/buffer_spec.lua
Commit message (Collapse)AuthorAge
* fix(terminal): [Process exited] msg hides last line of full screen #42349Justin M. Keyes5 days
| | | | | | | | | Problem: If a job exits with cursor at last row, the `[Process exited]` message covers the text of that row. Solution: Start a new line before showing the message, like the old `\r\n[Process exited]` did.
* vim-patch:9.2.1114: Visual selection is not highlighted at the cursor ↵Takumi Katase2026-09-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | position #42105 vim-patch:9.2.1114: Visual selection is not highlighted at the cursor position Problem: In a terminal the character under the cursor is normally not shown as part of the visual selection. Solution: Don't set "noinvcur" in win_line() (Shane Harper). The problem did not occur in the GUI, only in a terminal. The name "noinvcur" ("don't invert the cursor") was misleading: the variable did not affect the cursor, but whether the character under the cursor could be displayed as part of the visual selection. The "noinvcur" handling may have been meant to help during a visual selection when Visual is shown in reverse video and the terminal draws the cursor by inverting the character under it, as otherwise the character under the cursor would not look highlighted like the rest of the selection. But Vim cannot know in general how a terminal draws the cursor, and when either the cursor is not drawn by inverting the character under it or Visual is not shown in reverse video, the handling just left a character of the visual selection unhighlighted. closes: vim/vim#21317 https://github.com/vim/vim/commit/d10aab4ba6602f8f2f2576d2d62ceb63869db6fb Co-authored-by: Shane Harper <shane@shaneharper.net> AI-assisted
* fix(terminal): some keys like S-Del not working (#42080)zeertzjq2026-09-25
| | | | Problem: Some keys like S-Del not working in Terminal mode. Solution: Reverse the effect of simplify_key().
* vim-patch:8.2.1353: crash when drawing double-wide character in terminal ↵zeertzjq2026-09-15
| | | | | | | | | | | window (#41858) Problem: Crash when drawing double-wide character in terminal window. (Masato Nishihata) Solution: Check getcell() returning NULL. (issue vim/vim#6141) https://github.com/vim/vim/commit/8b89614e69b9b2330539d0482e44f4724053e780 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* fix(terminal): check file timestamps on terminal-job exit #41814Justin M. Keyes2026-09-09
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: When a `:!` command runs, file timestamps are checked and W12 or `FileChangedShell` is triggered. But not when a `:terminal` job exits. Only `enter_buffer()` checks, so whether you get the W12 warning depends on how you happen to return to the file: `:term` works, `:tabnew | term` does not. echo foo > testfile nvim --clean testfile " Edit the buffer, don't save it. :!mv testfile testfile2 :tabnew | term sh touch testfile2 && mv testfile2 testfile exit 'autoread' is defeated because `:!mv` deletes the file, so `should_watch()` fails and the watcher stops. `ensure_watcher()` only re-runs on `BufReadPost`/`BufWritePost`/`OptionSet`, so nothing watches the file when the terminal moves it back. Solution: Set `need_check_timestamps` on terminal-job exit, same as `:!cmd` (`os_shell`).
* fix(cmdwin): allow a user to switch to other buffers #41199Rob Pilling2026-08-28
|
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* test: unreliable ":terminal buffer … partial mappings" #40806Justin M. Keyes2026-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: FAILED …/terminal/buffer_spec.lua @ 348: :terminal buffer is refreshed with partial mappings in Normal mode …/terminal/buffer_spec.lua:348: Row 2 did not match. Expected: |tty ready | |*^jjjjjjjjjj | | | | | | | | | | | Actual: |tty ready | |*^jjjjjjjjj | | | | | | | | | | | Solution: Increase sleep time.
* fix(mouse): reset click count on next click if mouse moved (#40637)zeertzjq2026-07-09
| | | Also, drop drag event if the mouse hasn't moved, like in gVim.
* fix(terminal): avoid E676 after failed :wqa (#40620)Barrett Ruth2026-07-07
|
* fix(terminal): memory leak when pasting '=' register (#39738)zeertzjq2026-05-11
| | | | Problem: Memory leak when pasting '=' register in terminal. Solution: Free the register.
* feat(events)!: support `Optionset modified`, drop BufModifiedSet #35610glepnir2026-04-27
| | | | | | | | | Problem: BufModifiedSet autocmd only triggered for current buffer during redraw, causing delayed events when :wa writes non-current buffers. Solution: - Use the aucmd_defer approach to implement `Optionset modified`. - Drop BufModifiedSet.
* refactor: update usages of deprecated "buffer" param #39089Justin M. Keyes2026-04-15
|
* test(terminal/buffer_spec): increase timeout waiting for REP (#38398)zeertzjq2026-03-21
| | | | On Windows, 10000 milliseconds is sometimes not enough for 20000 lines to be printed. Add 1 millisecond timeout for each printed line.
* fix(terminal): don't poll for output during scrollback refresh (#38365)zeertzjq2026-03-19
| | | | | | | | 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.
* fix(terminal): don't always leave if enter autocmds delete buffer #38324Sean Dewar2026-03-16
| | | | | | | 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.
* fix(terminal): heap UAF from autocmds when entering #38316Sean Dewar2026-03-15
| | | | | | 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.
* docs: use "ev" convention in event-handlersJustin M. Keyes2026-03-12
| | | | | | | | | 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.
* fix(terminal): free the "[Process exited]" msg extmark #38246Ayaan2026-03-11
| | | | | | | 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.
* feat(terminal): surface exit code via virttext + nvim_get_chan_info #37987Ayaan2026-03-10
| | | | | | | | | | 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.
* test: remove remaining use of feed_command() in terminal/ (#38069)zeertzjq2026-02-26
| | | Also deduplicate screen lines in some other tests.
* refactor(test): avoid deprecated functions #37017glepnir2026-02-24
| | | | | | | Problem: Tests are using some deprecated functions. Solution: Replace with command, pcall_err, etc.
* test: fix flaky tests in terminal/{buffer,channel}_spec.lua (#37966)zeertzjq2026-02-19
| | | | In buffer_spec.lua, wait for a bit more than the refresh delay. In channel_spec.lua, retry sending lines on Windows.
* refactor(terminal): don't put cursor at bottom-left in Normal mode (#37873)zeertzjq2026-02-15
| | | | | | | | | | 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.
* fix(terminal): resuming doesn't work with command in fish (#37857)zeertzjq2026-02-14
| | | | | | | | | | | 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.
* fix(terminal): missing refresh with partial mappings (#37839)zeertzjq2026-02-14
| | | | | Problem: Terminal buffers are not refreshed when processing keys that trigger partial mappings. Solution: Process due terminal refreshes before redrawing.
* feat(terminal): detect suspended PTY process (#37845)zeertzjq2026-02-13
| | | | | | | 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.
* fix(terminal): set b_locked when setting &buftype (#37787)Sean Dewar2026-02-09
| | | | | | 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.
* fix(terminal): handle split composing chars at right edge (#37694)zeertzjq2026-02-05
| | | | | | | | 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.
* fix(terminal): also don't propagate $COLORTERM on Windows (#37699)zeertzjq2026-02-04
| | | The same reason in #26440 applies to Windows as well.
* ci(test): bump Windows runners to windows-2025 and unskip tests (#37666)zeertzjq2026-02-03
| | | | 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.
* test(terminal): status is -1 in TermClose if buffer is deleted (#37609)zeertzjq2026-01-29
|
* fix(terminal): wrong scrollback with BufFile* autocommand (#37601)zeertzjq2026-01-28
| | | | | | 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.
* fix(terminal): losing output if BufFile* poll for events (#37580)zeertzjq2026-01-28
| | | | | | 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.
* fix(terminal): don't allow b:term_title watcher to delete bufferzeertzjq2026-01-27
|
* fix(terminal): losing scrollback when TermOpen polls for events (#37573)zeertzjq2026-01-27
| | | | | 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.
* fix(terminal): <Ignore> should be no-op (#37494)zeertzjq2026-01-22
|
* fix(terminal): restore options properly when switching buffer (#37485)zeertzjq2026-01-21
|
* fix(process): don't limit PTY master remaining data sizezeertzjq2026-01-15
|
* fix(terminal): :edit should respect 'bufhidden' with exited job (#37301)zeertzjq2026-01-10
|
* vim-patch:9.1.2066: :wqall! doesn't close a terminal like :qall! does (#37314)zeertzjq2026-01-08
| | | | | | | | | | | | | 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
* test(terminal/buffer_spec): fix flaky test (#37299)zeertzjq2026-01-08
| | | | 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.
* fix(buffer): don't reuse 1-line terminal buffer (#37261)zeertzjq2026-01-06
| | | | | | | | | | | | | | | | | | 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...
* fix(terminal): avoid multiple terminals writing to same buffer (#37219)zeertzjq2026-01-05
| | | | | | | | | 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.
* fix(terminal): crash with race between buffer close and OSC 2 (#37225)zeertzjq2026-01-05
| | | | | | 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.
* fix(terminal): handle closing terminal with pending TermRequest (#37227)zeertzjq2026-01-04
| | | | | | | 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.
* fix(terminal): wrong row in TermRequest with full scrollback (#36298)zeertzjq2025-10-24
| | | | Problem: Wrong row in TermRequest with full scrollback. Solution: Subtract by the number of lines deleted from scrollback.
* fix(terminal): patch various autocommand-related holesSean Dewar2025-08-26
| | | | | | | | | | | | | | | 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.
* fix(terminal): update winopts and focus when switching terminalsSean Dewar2025-08-26
| | | | | | | Problem: window options and terminal focus notifications not updated when switching terminals without leaving terminal mode. Solution: update them.
* test(tui_spec): flakiness, global highlight definitions #34958luukvbaal2025-07-16
|