aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/screen.lua
Commit message (Collapse)AuthorAge
* fix(cwd): stale buffer names after temp context-switch #41433Justin M. Keyes2026-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 1. `ctx_dirs_restore()` is the only chdir site that doesn't re-shorten buffer names; `post_chdir()`, `update_cwd()` and `do_autochdir()` all call `shorten_fnames(true)`. So after a temp window-context switch that moved the CWD, every buffer's `b_fname` is still relative to the other directory. ui2 renders messages in a float, and entering it is such a switch, so with a `:bcd` in a `BufReadPost` handler 'statusline' "%f" shows ".config/nvim/init.lua" while the CWD is already `~/.config/nvim`, and :write resolves the name against it: ``` E212: Can't open file for writing: no such file or directory ``` 2. `msg_multihl()` leaves `msg_ext_id` pointing at the caller's storage when nothing was emitted (e.g. 'msg_silent'): the reset only ran on a flush that produced chunks. The next message then ships a dead stack frame as its msg_show id. After ":silent write" the id is buf_write()'s `msg_id[MAXPATHL + 32]`: ``` id = "\0\0\0\0\0\0\0\0\29\0(<C6>k\24R\17p<C7><C7><C7>\1\0\0\0..." ``` Solution: 1. `shorten_fnames(true)` after restoring the CWD. Drop `cs_save_sfname`, which was a partial workaround for the same bug. 2. Release the id in `msg_multihl()`, where it is set and the caller's frame is still alive. Stop reading `.data.integer` out of a String union member.
* feat(fs): vim.fs.normalize{plain:boolean} #41127Olivia Kinnear2026-08-05
| | | | | | `opts.plain=true` does not expand tildes in addition to environment variables, unlike `opts.expand_env=false`. `opts.expand_env=false` is soft-deprecated.
* fix(ui): combine float border with window background #40796Artem Krinitsyn2026-07-19
| | | | | | | | | | Problem: Float border highlight groups (FloatBorder, FloatTitle and FloatFooter) fall back to Normal background highlight if no background color set. Solution: Combine border colors with window-local Normal highlight. Fix #38330
* fix(test): `screen:expect({none=…})` with no any/gridJustin M. Keyes2026-07-10
| | | | | | | | | Problem: `screen:expect({none=…})` with no any/grid crashed (concat on nil) because actual_rows was only rendered when any or grid was present. Solution: Update the condition.
* fix(test): screen:expect() render crash masks the real failure #40593Justin M. Keyes2026-07-05
| | | | | | | | | | | | | | | | | | | | | | Problem: When screen:expect() fails, it renders a snapshot for the error message. If the grid references a highlight id that was never defined via "hl_attr_define", the renderer crashes: screen.lua:1910: attempt to index local 'entry' (a nil value) This hides the actual failure, and appears "flaky": it only fires on the failure path, and only when the shared screen is missing an id the grid still references. A screen created in setup() attaches mid-session, so highlight ids allocated before it attached (still referenced by stale grid cells) are never sent to it. Solution: - Don't crash while rendering a diagnostic: show undefined highlight ids as "UNKNOWN_HL_ID(n)", so the real failure and the desync are legible. - put_spec: fix `visualbell` typo. If it fails again then we can find the actual root cause. ref https://github.com/neovim/neovim/issues/36250
* fix(cmdline): encode no prompt in cmdline_show.hl_idLuuk van Baal2026-06-22
| | | | | | Problem: Unable to distinguish an empty prompt from no prompt in cmdline_show event. Solution: Set cmdline_show.hl_id to -1 when no prompt is active.
* test: run Lua harness with nvim -lLewis Russell2026-05-13
| | | | | | | | | | | | | | | | | | Problem: The Lua test harness still ran through standalone -ll mode, so tests depended on the low-level Lua path instead of the regular Nvim Lua environment. That also meant os.exit() coverage had to carry an ASAN workaround because Lua's raw process exit skipped Nvim teardown and let LeakSanitizer interfere with the observed exit code. Solution: Run the harness and related fixtures with nvim -l. Patch os.exit() in the main Lua state to exit through getout(), so scripts observe normal Nvim shutdown while standalone -ll remains available for generator-style scripts. As a consequence, the startup test can assert os.exit() without disabling leak detection. AI-assisted: Codex
* fix(messages): "progress" kind for busy messages #39280luukvbaal2026-04-21
| | | | | | | | | | Problem: The "Scanning:" completion, bufwrite, and indent (there may be more) messages which indicate progress can use the "progress" kind for their msg_show event. Indent message does not have a kind. Solution: Emit these messages with the "progress" kind. Set the message id to the replaced kind so that a UI knows to replace it (and to provide a migration path in case a UI was distinguishing these messages for whatever reason).
* test: replace busted with local harnessLewis Russell2026-04-15
| | | | | | | | | | | | | | | | | | | Replace the busted-based Lua test runner with a repo-local harness. The new harness runs spec files directly under `nvim -ll`, ships its own reporter and lightweight `luassert` shim, and keeps the helper/preload flow used by the functional and unit test suites. Keep the file boundary model shallow and busted-like by restoring `_G`, `package.loaded`, `package.preload`, `arg`, and the process environment between files, without carrying extra reset APIs or custom assertion machinery. Update the build and test entrypoints to use the new runner, add black-box coverage for the harness itself, and drop the bundled busted/luacheck dependency path. AI-assisted: Codex
* test: always show snapshot if screen:expect_unchanged() fails (#38347)zeertzjq2026-03-18
| | | | If the final screen state does match but an intermediate screen state doesn't, show the first intermediate state.
* fix(winfloat): last_status when changing split to floatwinSean Dewar2026-03-14
| | | | | | | | | | | | Problem: converting a split to a floatwin may not remove the last statusline when needed. (e.g: 'ls' is 1) Solution: call last_status/win_comp_pos in win_new_float, after win_remove. Also fix float_pos formatting for screen snapshots so it doesn't give a nil error for external windows. Not an issue from this PR.
* feat(ui): specify whether msg_show event comes from typed commandLuuk van Baal2026-03-03
| | | | | | | | | | Problem: Unable to tell whether a msg_show event is emitted as a result a command typed on the cmdline (UI may want to represent these differently from other messages). Solution: Add trigger parameter that is set to "typed_cmd" for a message emitted due to an interactively typed command. Possible extensions are mapping/timer/event but it's hard to imagine a UI distinguishing those so not added here.
* test(screen): fix minimal timeout too small for "intermediate" (#37933)zeertzjq2026-02-18
| | | | After #27620 flags.timeout is no longer used as the minimal timeout for "intermediate", but the default minimal timeout shouldn't be too small.
* test: fix some type warnings (#37483)zeertzjq2026-01-21
|
* test: make it possible to test multiple screen string matchesFred Sundvik2025-09-03
| | | | | | | | | | | | | Problem: Currently it's only possible to test a single string match in the screen, which makes it hard match multiple strings in the screen to avoid having to compare the whole screen state. It's also not possible to test if a string match is not found in the screen. Solution: Support an array of `any` matches and also support `none`, which does a negative comparision.
* feat(api): nvim_echo can emit Progress messages/events #34846Shadman2025-08-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Nvim does not have a core concept for indicating "progress" of long-running tasks. The LspProgress event is specific to LSP. Solution: - `nvim_echo` can emit `kind="progress"` messages. - Emits a `Progress` event. - Includes new fields (id, status, percent) in the `msg_show` ui-event. - The UI is expected to overwrite any message having the same id. - Messages have a globally unique ID. - `nvim_echo` returns the message ID. - `nvim_echo(… {id=…})` updates existing messages. Example: local grp = vim.api.nvim_create_augroup("Msg", {clear = true}) vim.api.nvim_create_autocmd('Progress', { pattern={"term"}, group = grp, callback = function(ev) print(string.format('event fired: %s', vim.inspect(ev))..'\n') end }) -- require('vim._extui').enable({enable=true, msg={target='msg', timeout=1000}}) vim.api.nvim_echo({{'searching'}}, true, {kind='progress', percent=80, status='running', title="terminal(ripgrep)"}) local id = vim.api.nvim_echo({{'searching'}}, true, {kind='progress', status='running', percent=10, title="terminal(ripgrep)"}) vim.api.nvim_echo({}, true, {id = id, kind='progress', percent=20, status = 'running', title='find tests'}) vim.api.nvim_echo({}, true, {id = id, kind='progress', status='running', percent=70}) vim.api.nvim_echo({{'complete'}}, true, {id = id, kind='progress', status='success', percent=100, title="find tests"}) Followups: - Integrate with 'statusline' by listening to the Progress autocmd event. - Integrate progress ui-event with `vim._extui`.
* feat(tui): add nvim_ui_send (#35406)Gregory Anders2025-08-22
| | | | This function allows the Nvim core to write arbitrary data to a TTY connected to a UI's stdout.
* fix(ui): check for cmdline mode properly (#35202)zeertzjq2025-08-07
|
* test(screen): remove screen:get_default_attr_ids() (#34973)luukvbaal2025-07-17
| | | | | | | Problem: get_default_attr_ids() is used to get and change a subset of the current highlight definitions in {fold,popupmenu}_spec.lua, for which we have add_extra_attr_ids(). Solution: Use global highlight definitions and use add_extra_attr_ids to replace.
* test(messages/cmdline_spec): convert highlight IDs to name and format (#34845)luukvbaal2025-07-09
| | | | | | | Problem: Hardcoded highlight IDs for ext_messages/cmdline output need to be adjusted everytime a builtin highlight group is added. Solution: Store a global map of default highlights through nvim_get_hl() and fetch missing (custom) highlight groups through synIDattr(). Use more compact formatting for screen:expect().
* feat(messages): add "prev_cmd" argument to msg_history_show (#34779)luukvbaal2025-07-08
| | | | | Problem: Unable to tell whether msg_history_show event is emitted for a :messages or g< command. Solution: Add "prev_cmd" argument that is set to true for g<.
* fix(ui)!: decouple ext_messages from message grid #27963luukvbaal2025-06-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ext_messages is implemented to mimic the message grid implementation w.r.t. scrolling messages, clearing scrolled messages, hit-enter-prompts and replacing a previous message. Meanwhile, an ext_messages UI may not be implemented in a way where these events are wanted. Moreover, correctness of these events even assuming a "scrolled message" implementation depends on fragile "currently visible messages" global state, which already isn't correct after a previous message was supposed to have been overwritten (because that should not only happen when `msg_scroll == false`). Solution: - No longer attempt to keep track of the currently visible messages: remove the `msg_ext(_history)_visible` variables. UIs may remove messages pre-emptively (timer based), or never show messages that don't fit a certain area in the first place. - No longer emit the `msg(_history)_clear` events to clear "scrolled" messages. This opens up the `msg_clear` event to be emitted when messages should actually be cleared (e.g. when the screen is cleared). May also be useful to emit before the first message in an event loop cycle as a hint to the UI that it is a new batch of messages (vim._extui currently schedules an event to determine that). - Set `replace_last` explicitly at the few callsites that want this to be set to true to replace an incomplete status message. - Don't store a "keep" message to be re-emitted.
* fix(messages): add append parameter to history entries (#34467)luukvbaal2025-06-15
| | | | | | | | Problem: The "append" parameter added in abb40ece is missing from history entries, resulting in different message formatting for "g<". Solution: Add "append" field to message history entries. Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
* test(screen): still match by full row when {MATCH:} is present (#34437)zeertzjq2025-06-11
| | | | | Add '^' and '$' around the pattern. This makes it less likely to make mistakes of when writing tests with {MATCH:}, as most such tests have text before and after {MATCH:}.
* feat(ui): "append" parameter for "msg_show" UI eventsLuuk van Baal2025-05-24
| | | | | | | | | | | | Problem: Consecutive "msg_show" events stemming from an `:echon` command are supposed to be appended without a newline, this information is not encoded in the "msg_show" event. Solution: Add an "append" parameter to the "msg_show" event that is set to true to indicate the message should not start on a new line. Considered alternative: Emit a newline for the common case instead at the start of a new message. That way UIs can more closely follow the logic as it is implemented for the message grid currently. This would be a breaking change. The "append" parameter seems OK.
* fix(ui): correct condition for "wrap" flag in a floating gridbfredl2025-04-30
| | | | | | | | In a floating window grid, "wrap" flag should not be set when vertical borders are used, as the the wrapped text will be broken up by border chars. fixes #33719
* feat(ui): include compositor info with multigridFred Sundvik2025-04-15
| | | | | Provide compositor information, like composition index and absolute position.
* fix(ui): send multigrid message position and size when the UI is refreshedFred Sundvik2025-03-27
|
* feat(lua): vim.text.indent()Justin M. Keyes2025-02-26
| | | | | | | | | | | | | Problem: Indenting text is a common task in plugins/scripts for presentation/formatting, yet vim has no way of doing it (especially "dedent", and especially non-buffer text). Solution: Introduce `vim.text.indent()`. It sets the *exact* indentation because that's a more difficult (and thus more useful) task than merely "increasing the current indent" (which is somewhat easy with a `gsub()` one-liner).
* test(fix): make testing of ext_cmdline optional #32375fredizzimo2025-02-10
|
* test: reset cmdline abort state only after expect() has finished #32376fredizzimo2025-02-09
| | | | | | | Problem: cmdline abort state may be reset when intermediate states are received. Solution: Reset after `self:_wait()`.
* test: screen.lua can check win_pos #32373fredizzimo2025-02-09
| | | Also remove a hack in the multigrid "with winbar" test.
* feat(ui): specify whether msg_show event is added to historyLuuk van Baal2024-12-23
| | | | | Pass along whether message in msg_show event is added to the internal :messages history.
* feat(ui): additional arguments for cmdline_show/hide eventsLuuk van Baal2024-12-22
| | | | | | | | Problem: Unable to tell what highlight the prompt part of a cmdline_show event should have, and whether cmdline_hide was emitted after aborting. Solution: Add additional arguments hl_id to cmdline_show, and abort to cmdline_hide.
* 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.
* test(screen): adjust screen state per stylua #31441luukvbaal2024-12-04
| | | | | | | | | | | | | | | | | | | | | | | | | Before: screen:expect({ | screen:expect({ grid = [[ | grid = [[ {10:>!}a | | line ^1 | {7: }b | | {1:~ }|*4 {10:>>}c | | ]], messages={ { {7: }^ | | content = { { "\ntest\n[O]k: ", 6, 11 } }, {1:~ }|*9 | kind = "confirm" | | } } ]] | }) }) After: screen:expect([[ | screen:expect({ {10:>!}a | | grid = [[ {7: }b | | line ^1 | {10:>>}c | | {1:~ }|*4 {7: }^ | | ]], {1:~ }|*9 | messages = { { | | content = { { "\ntest\n[O]k: ", 6, 11 } }, ]]) | kind = "confirm" | } }, | })
* 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.
* feat(ext_messages): add hl_id to ext_messages chunksLuuk van Baal2024-11-09
| | | | | | | | Problem: Ext_messages chunks only contain the highlight attr id, which is not very useful for vim.ui_attach() consumers. Solotion: Add highlight group id to message chunks, which can easily be used to highlight text in the TUI through nvim_buf_set_extmark(): hl_group = synIDattr(id, "name").
* test: fix reporting "no flush received" too early (#29735)zeertzjq2024-07-17
|
* refactor(lua): use tuple syntax everywhere #29111Ilia Choly2024-06-04
|
* refactor(tests): update screen:snapshot_util() to use new-style highlightsbfredl2024-05-25
| | | | | | | | | | | This makes screen:snapshot_util() generate code with the new screen:add_extra_attr_ids { ... } pattern. For convenience, the old-style configuration is still detected and supported (until all tests have been refactored, which is my goal for the 0.11 cycle) Remove the last traces of the "ignore" attr anti-pattern. This code is no longer functional, it is just "ignore" argument being passed around like a hot potato at this point.
* 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.
* test: remove unnecessary nil argument to testutil (#28270)zeertzjq2024-04-11
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* refactor(tests): allow to extend the new base set of attrsbfredl2024-04-02
| | | | | | | | | | | We start at 100 so we can make the base set larger if needed. (It might need to grow/shrink as a result of adopting the new default color scheme as the default for tests) Usage best illustrataded by example. Improving the workflow for making new tests with `screen:snapshot_util()` will be a follow up.
* feat(ui): indicate margins for the area used by win_viewportbfredl2024-03-29
| | | | | | | | Problem: using win_viewport for implementing smooth scrolling in an external UI might run into problems when winbar or borders is used, as there is no indication that the entire grid is not used for scrolled buffer text. Solution: add `win_viewport_margins` event.
* test: print screen snapshot in desired format (#28088)luukvbaal2024-03-29
| | | | Problem: Screen snapshot is printed in a way that still needs to be formatted. Solution: Adjust the snapshot formatting (indentation, braces).
* fix(test): typingLewis Russell2024-03-25
|
* refactor(tests): all screen tests should use highlightsbfredl2024-03-23
| | | | | | | | | | | | | | | | | | | | | | | This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration)
* 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.