aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/tui_spec.lua
Commit message (Collapse)AuthorAge
* Merge #32001 from MariaSolOs/consistent-namespacesJustin M. Keyes2025-01-15
|\
| * refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano2025-01-14
| |
* | feat(terminal): support theme update notifications (DEC mode 2031) (#31999)Gregory Anders2025-01-14
|/
* refactor(tests): merge n.spawn/n.spawn_argv into n.new_session #31859Justin M. Keyes2025-01-04
| | | | | | | | | | | | | | | | | Problem: - `n.spawn()` is misleading because it also connects RPC, it's not just "spawning" a process. - It's confusing that `n.spawn()` and `n.spawn_argv()` are separate. Solution: - Replace `n.spawn()`/`n.spawn_argv()` with a single function `n.new_session()`. This name aligns with the existing functions `n.set_session`/`n.get_session`. - Note: removes direct handling of `prepend_argv`, but I doubt that was important or intentional. If callers want to control use of `prepend_argv` then we should add a new flag to `test.session.Opts`. - Move `keep` to first parameter of `n.new_session()`. - Add a `merge` flag to `test.session.Opts` - Mark `_new_argv()` as private. Test should use clear/new_session/spawn_wait instead.
* feat(clipboard)!: use OSC 52 as fallback clipboard provider (#31730)Gregory Anders2024-12-31
| | | | | | | | | | | | | | | We currently enable the OSC 52 clipboard provider by setting g:clipboard when a list of conditions are met, one of which is that $SSH_TTY must be set. We include this condition because often OSC 52 is not the best clipboard provider, so if there are "local" providers available Nvim should prefer those over OSC 52. However, if no other providers are available, Nvim should use OSC 52 even when $SSH_TTY is not set. When a user is in an SSH session then the checks for the other clipboard providers will still (typically) fail, so OSC 52 continues to be enabled by default in SSH sessions. This is marked as a breaking change because there are some cases where OSC 52 wasn't enabled before and is now (or vice versa).
* feat(jobs): jobstart(…,{term=true}), deprecate termopen() #31343Justin M. Keyes2024-12-19
| | | | | | | | | | | | Problem: `termopen` has long been a superficial wrapper around `jobstart`, and has no real purpose. Also, `vim.system` and `nvim_open_term` presumably will replace all features of `jobstart` and `termopen`, so centralizing the logic will help with that. Solution: - Introduce `eval/deprecated.c`, where all deprecated eval funcs will live. - Introduce "term" flag of `jobstart`. - Deprecate `termopen`.
* feat(terminal)!: cursor shape and blink (#31562)Gregory Anders2024-12-17
| | | | | | | | | | | | | | | | | | | | | When a terminal application running inside the terminal emulator sets the cursor shape or blink status of the cursor, update the cursor in the parent terminal to match. This removes the "virtual cursor" that has been in use by the terminal emulator since the beginning. The original rationale for using the virtual cursor was to avoid having to support additional UI methods to change the cursor color for other (non-TUI) UIs, instead relying on the TermCursor and TermCursorNC highlight groups. The TermCursor highlight group is now used in the default 'guicursor' value, which has a new entry for Terminal mode. However, the TermCursorNC highlight group is no longer supported: since terminal windows now use the real cursor, when the window is not focused there is no cursor displayed in the window at all, so there is nothing to highlight. Users can still use the StatusLineTermNC highlight group to differentiate non-focused terminal windows. BREAKING CHANGE: The TermCursorNC highlight group is no longer supported.
* fix(tests): needing two calls to setup a screen is cringebfredl2024-11-14
| | | | | | | | | | Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
* fix(tui): avoid flushing buffer halfway an OSC 2 sequence (#30793)zeertzjq2024-10-15
| | | | | | Problem: Setting title while TUI buffer is almost full may cause the end of a flush to be treated as a part of an OSC 2 or OSC 0 sequence, leading to problems like invisible cursor. Solution: Make the whole sequence to set title a unibi_ext string.
* test(tui_spec): use Unicode in cursor_address test (#30807)zeertzjq2024-10-14
| | | | | | Now that #16425 is fixed, use Unicode again to reduce screen height. Unfortunately composing chars still can't be used, as it turns out that composing chars may be missing when sent separately from the base char at the last char a screen line.
* test(tui_spec): use child_exec_lua() more (#30757)zeertzjq2024-10-11
| | | It is more readable.
* test(tui_spec): better prevent race between paste and input (#30751)zeertzjq2024-10-11
| | | | | | | | | | Problem: Using a single RPC request to child server isn't enough to prevent race between nvim_paste and nvim_input. Solution: Ensure both child client and child server have processed pending events by sending an empty DCS response to the child client and waiting for TermResponse autocommand on the child server.
* feat(paste): unify cancel and error behavior (#30476)zeertzjq2024-09-24
| | | | | | | | | | | | | | | | | | | | | | | | Before this PR, the behavior of nvim_paste is: - When vim.paste() returns false, return false to the client, but treat following chunks normally (i.e. rely on the client cancelling the paste as expected). - When vim.paste() throws an error, still return true to the client, but drain the following chunks in the stream without calling vim.paste(). There are two problems with such behavior: - When vim.paste() errors, the client is still supposed to send the remaining chunks of the stream, even though they do nothing. - Having different code paths for two uncommon but similar situations complicates maintenance. This PR makes both the cancel case and the error case return false to the client and drain the remaining chunks of the stream, which, apart from sharing the same code path, is beneficial whether the client checks the return value of nvim_paste or not: - If the client checks the return value, it can avoid sending the following chunks needlessly after an error. - If the client doesn't check the return value, chunks following a cancelled chunk won't be pasted on the server regardless, which leads to less confusing behavior.
* test(tui_spec): prevent another case of race between paste and input (#30481)zeertzjq2024-09-23
| | | | | Problem: When input immediately follows end of bracketed paste, the nvim_input may be processed before the nvim_paste. Solution: Ensure some waiting after the end of a bracketed paste.
* fix(paste): improve repeating of pasted text (#30438)zeertzjq2024-09-22
| | | | | | | - Fixes 'autoindent' being applied during redo. - Makes redoing a large paste significantly faster. - Stores pasted text in the register being recorded. Fix #28561
* feat(tui): builtin UI (TUI) sets client info #30397Justin M. Keyes2024-09-18
| | | | | | | | | | | | Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later.
* refactor(tests): rename terminal/testutil.lua => testterm.lua #30372Justin M. Keyes2024-09-15
| | | | | This module is generally used by any tests that need the full Nvim TUI instead of `screen.lua`. Thus it should live in `functional/` instead of in `functional/terminal/`.
* feat(defaults): popupmenu "Open in browser", "Go to definition" #30261Justin M. Keyes2024-09-05
| | | | - Use the popup to expose more features such as LSP and gx. - Move the copy/paste items lower in the menu, they are lower priority.
* fix(tui): set id parameter in OSC 8 sequences (#29840)Gregory Anders2024-07-24
| | | | | | | | | The id parameter is used to communicate to the terminal that two URLs are the same. Without an id, the terminal must rely on heuristics to determine which cells belong together to make a single hyperlink. See the relevant section in the spec [1] for more details. [1]: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
* fix(ui): avoid ambiguity about last chunk when flushing halfway (#29718)zeertzjq2024-07-15
|
* fix(highlight): add `StatusLineTerm`/`StatusLineTermNC` to `:color vim` (#29313)Evgeni Chasnovski2024-06-14
| | | | | | | | | | | | | | | Problem: both `StatusLineTerm`/`StatusLineTermNC` are now explicitly used, but `:color vim` does not set them to the values used in Vim. This might be fine if `:color vim` is treated as "the state of default color scheme prior the big update", but it seems to be better treated as "Vim's default color scheme" (how it is documented in its header). Solution: add `StatusLineTerm`/`StatusLineTermNC` definitions to 'runtime/colors/vim.lua'. Use explicit foreground colors ('Whte'/'Black') instead of `guifg=bg` used in source, as the latter caused some problems in the past (if `Normal` is not defined, `nvim_set_hl()` can't recognize `'bg'` as the foreground value). Also realign the rest of the background conditional highlight groups.
* fix(tui): move $COLORTERM check to _defaults.lua (#29197)Gregory Anders2024-06-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently check $COLORTERM in the TUI process to determine if the terminal supports 24 bit color (truecolor). If $COLORTERM is "truecolor" or "24bit" then we automatically assume that the terminal supports truecolor, but if $COLORTERM is set to any other value we still query the terminal. The `rgb` flag of the UI struct is a boolean which only indicates whether the UI supports truecolor, but does not have a 3rd state that we can use to represent "we don't know if the UI supports truecolor". We currently use `rgb=false` to represent this "we don't know" state, and we use XTGETTCAP and DECRQSS queries to determine at runtime if the terminal supports truecolor. However, if $COLORTERM is set to a value besides "truecolor" or "24bit" (e.g. "256" or "16) that is a clear indication that the terminal _does not_ support truecolor, so it is incorrect to treat `rgb=false` as "we don't know" in that case. Instead, in the TUI process we only check for the terminfo capabilities. This must be done in the TUI process because we do not have access to this information in the core Neovim process when `_defaults.lua` runs. If the TUI cannot determine truecolor support from terminfo alone, we set `rgb=false` to indicate "we don't know if the terminal supports truecolor yet, keep checking". When we get to `_defaults.lua`, we can then check $COLORTERM and only query the terminal if it is unset. This means that users can explicitly opt out of truecolor determination by setting `COLORTERM=256` (or similar) in their environment.
* fix(tui): reset clear_region attributes during startup #28713luukvbaal2024-05-26
| | | | | | Problem: Fix added in #28676 worked accidentally(used variables were themselves uninitialized at this point during startup) and does not always work. Solution: Reset attributes when clearing regions during startup.
* fix(tui): initialize clear attrs with current terminal backgroundLuuk van Baal2024-05-10
| | | | | | | Problem: Invalidated regions that are flushed during startup are cleared with unitialized "clear_attrs", which is perceived as flickering. Solution: Initialize "clear_attrs" with current terminal background color.
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* fix(tui): make setcellwidths() work for non-ambiwidth chars (#28322)zeertzjq2024-04-14
|
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: silence expected errorsdundargoc2024-04-02
| | | | This will remove unrelated errors in .nvimlog at the end of test output.
* feat(tui): query extended underline support using DECRQSS (#28052)zeertzjq2024-03-28
|
* test(tui_spec): fix flaky test for isolated "stop paste" (#28053)zeertzjq2024-03-27
| | | In rare cases there may be multiple chunks of phase 2 because of timing.
* test(terminal/cursor_spec): unskip tests that pass on Windows (#27924)zeertzjq2024-03-19
| | | | | Also: - Make indent of test cases consistent. - Unskip TUI rapid resize test with ASAN as reflow is now disabled.
* test: don't use minimal timeout for "intermediate" flag (#27620)zeertzjq2024-02-25
| | | | | | With "intermediate" flag, only using minimal timeout is too short and may lead to failures. Also remove the fallback timeout in screen:expect_unchanged(), as having a different fallback timeout than screen:expect() is confusing.
* test: add test for scroll wheel at right-click menu (#27409)zeertzjq2024-02-10
|
* test(tui_spec): prevent race between nvim_input and nvim_paste (#27356)zeertzjq2024-02-06
|
* fix(tui): `space_buf` overflow when clearing screen (#27352)Sean Dewar2024-02-06
| | | | | | | | | Problem: `tui->space_buf` may be smaller than the width of the TUI or widest grid, causing an overflow when calling `tui_grid_clear` if `print_spaces` is called from `clear_region` (clears the TUI's screen since #23428). Solution: resize `space_buf` to be wide enough to fit the TUI or widest grid. Didn't bother shrinking the allocation if the max widths decrease.
* test(tui): add & improve tests for terminal queries (#27219)Gregory Anders2024-01-28
| | | | | | | | | | | | | | | | | | | Problems: 1. The test case for querying truecolor support did not check which capabilities were queried 2. The test case for querying truecolor support checked `&termguicolors` in the Nvim test runner, not the child Nvim in the the embedded terminal 3. The test case for querying truecolor support did not actually respond to the XTGETTCAP requests. `'termguicolors'` is still enabled even without responding to this query because libvterm understands and responds to the DECRQSS request, but it is still good to respond to the query explicitly instead of depending on hidden libvterm behavior 4. No test case exists at all for OSC 52 Solution: Fix all of the problems listed above.
* test(tui_spec): get &background from child session directly (#27224)zeertzjq2024-01-27
|
* feat(ui): add support for OSC 8 hyperlinks (#27109)Gregory Anders2024-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extmarks can contain URLs which can then be drawn in any supporting UI. In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control sequence to the TTY. On terminals which support the OSC 8 sequence this will create clickable hyperlinks. URLs are treated as inline highlights in the decoration subsystem, so are included in the `DecorSignHighlight` structure. However, unlike other inline highlights they use allocated memory which must be freed, so they set the `ext` flag in `DecorInline` so that their lifetimes are managed along with other allocated memory like virtual text. The decoration subsystem then adds the URLs as a new highlight attribute. The highlight subsystem maintains a set of unique URLs to avoid duplicating allocations for the same string. To attach a URL to an existing highlight attribute we call `hl_add_url` which finds the URL in the set (allocating and adding it if it does not exist) and sets the `url` highlight attribute to the index of the URL in the set (using an index helps keep the size of the `HlAttrs` struct small). This has the potential to lead to an increase in highlight attributes if a URL is used over a range that contains many different highlight attributes, because now each existing attribute must be combined with the URL. In practice, however, URLs typically span a range containing a single highlight (e.g. link text in Markdown), so this is likely just a pathological edge case. When a new highlight attribute is defined with a URL it is copied to all attached UIs with the `hl_attr_define` UI event. The TUI manages its own set of URLs (just like the highlight subsystem) to minimize allocations. The TUI keeps track of which URL is "active" for the cell it is printing. If no URL is active and a cell containing a URL is printed, the opening OSC 8 sequence is emitted and that URL becomes the actively tracked URL. If the cursor is moved while in the middle of a URL span, we emit the terminating OSC sequence to prevent the hyperlink from spanning multiple lines. This does not support nested hyperlinks, but that is a rare (and, frankly, bizarre) use case. If a valid use case for nested hyperlinks ever presents itself we can address that issue then.
* feat(terminal): respond to OSC background and foreground request (#17197)Daniel Steinberg2024-01-15
| | | | | | | | | | | | The motivation for this update is Issue #15365, where background=light is not properly set for Nvim running from an Nvim :terminal. This can be encountered when e.g., opening a terminal to make git commits, which opens EDITOR=nvim in the nested terminal. Under the implementation of this commit, the OSC response always indicates a black or white foreground/background. While this may not reflect the actual foreground/background color, it permits 'background' to be retained for a nested Nvim instance running in the terminal emulator. The behaviour matches Vim.
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: typing for helpers.methsLewis Russell2024-01-12
|
* feat(terminal): trigger TermRequest autocommand events (#22159)Ghjuvan Lacambre2024-01-09
| | | | | | | | | | This commit implements a new TermRequest autocommand event and has Neovim emit this event when children of terminal buffers emit an OSC or DCS sequence libvterm does not handle. The TermRequest autocommand event has additional data in the v:termrequest variable. Co-authored-by: Gregory Anders <greg@gpanders.com>
* fix(test/tui_spec): pass the expected NULL-sentinel to execl()James McCoy2024-01-06
| | | | | | | | | | | | Since execl() is a variadic function, it requries a NULL-terminal to indicate the end of its argument list, c.f. exec(3) > The first argument, by convention, should point to the filename > associated with the file being executed. The list of arguments *must* > be terminated by a null pointer This fixes the failure seen on aarch64 and i386, due to garbage data being considered part of the variadic arguments.
* refactor: format test/*Justin M. Keyes2024-01-03
|
* fix(tui): don't forget to update cursor visibility (#26523)zeertzjq2023-12-12
|
* test: avoid repeated screen lines in expected stateszeertzjq2023-12-09
| | | | | | This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
* refactor(tui): use synchronized updates around actual buf flush (#26478)Gregory Anders2023-12-09
| | | | | | | | | | | | | Rather than writing the synchronized update begin and end sequences into the TUI's internal buffer (where it is later flushed to the TTY), write these sequences directly to the TTY before and after the TUI's internal buffer is itself flushed to the TTY. This guarantees that a synchronized update is always used when we are actually sending data to the TTY. This means we do not need to keep track of the TUI's "dirty" state (any sequences which affect the TUI state will be written in the TUI's internal buffer, which is now guaranteed to only ever be written when a synchronized update is active).
* test(tui_spec): update cursor_address test for flush start (#26464)zeertzjq2023-12-08
|
* test: fix Windows tests failures (#26461)Gregory Anders2023-12-08
|