aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/cmdline_spec.lua
Commit message (Collapse)AuthorAge
* 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(messages): `inputlist()` offers the mouse when it cannot be used (#41280)Barrett Ruth2026-08-14
| | | | | | | | | | Problem: `inputlist()` advertises "click with the mouse" purely because it implements click selection, so under the default `'mouse'` of "nvi" it offers a click that command-line mode never receives. Solution: Only offer the mouse when `'mouse'` covers command-line mode, the same condition `:help inputlist()` already documents.
* feat(exmode): "1q:", :exmode #41010Justin M. Keyes2026-07-27
| | | | | | | | | Problem: Want `gQ` for _le multicursor_. Solution: - Don't use `gQ` for exmode. - Introduce `:exmode`. - Introduce `[count]q:` as an alias to `:exmode`.
* refactor(exmode): Ex-mode as cmdwin + Lua #40991Justin M. Keyes2026-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: POSIX-compatible Ex-mode requires special-cases all over the codebase to match various quirks that don't actually matter to users. - The main utility of *interactive* Ex-mode is its REPL behavior, and that can be achieved with `cmdwin`, which also gains extra UX benefits. - The main utility of *non-interactive* `nvim -es` is for shell scripting, where Ex-mode quirks are mostly unhelpful (e.g. the "Entering Ex mode" message). Solution: - Reimplement *interactive* Ex-mode as a "persistent, insert-mode cmdwin" in Lua. - "nvim -e/-E" is simply an alias to "gQ". - Reframe *non-interactive* Ex-mode (`nvim -es`) as "script mode". - Drop POSIX Ex-mode quirks. Improvements: - "nvim -V1 -es" output ends with a final newline! - "nvim -V1 -es" no longer shows the "Entering Ex mode" msg. (This was pointless noise, unwanted for scripting purposes.) - stdin is no longer typeahead. Scripts (":lua io.read()") can read stdin as data. - Empty line is a no-op: a stray blank line no longer moves the cursor (deviates from POSIX ex "+1"), no longer exits 1 at EOF (E501). Preserved behavior: - cursor starts at "$" - mode()=="cv" (for non-interactive) - multiline commands (:append/:function/heredoc pull continuation lines) - bare-range print - :print=>stdout - -V1=>stderr - CRLF input - continue-after-error and exit codes Dropped (regressed) POSIX behavior (non-interactive): - Event loop only ticks while/between commands, not while blocked waiting for a stdin line. - ":g/pat/visual...Q" - input()/getchar()/":s/x/y/c" no longer consume stdin lines as answers: Nvim stops at end-of-input, skipping the rest of the script, exit 0. Use ":lua io.read()" instead. - If users care about this they should use interactive Ex-mode (`gQ`). - ":@r" stops at end of the register instead of continuing to read cmdline input from stdin.
* 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`.
* fix(cmdwin): space in cmdwin-char 'statuscolumn'Justin M. Keyes2026-06-26
| | | | | To match the old behavior, the cmdwin-char should not be followed by a space char.
* fix(cmdwin): duplicate line in historyJustin M. Keyes2026-06-26
| | | | | | | | | Problem: After ctrl-f from the cmdline, the last 2 lines of cmdwin are redundant. Solution: In `open_cmdwin`, clear the live cmdline so that unwinding it (via Ctrl_C) does not add it to history.
* feat(cmdwin): implement cmdwin as a normal buf+winJustin M. Keyes2026-06-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: cmdwin (the `:q` cmdline buffer) has various limitations which require special-casing all over the codebase. Besides complicating the code, it also breaks async plugins if they try to create buffers/windows after some work is done, if the user happens to open cmdwin at the wrong the moment: Lua callback: …/guh.nvim/lua/guh/util.lua:531: E11: Invalid in command-line window; <CR> executes, CTRL-C quits stack traceback: [C]: in function 'nvim_buf_delete' …/guh.nvim/lua/guh/util.lua:531: in function <…/guh.nvim/lua/guh/util.lua:526> Solution: Just say no to "inception". Reimplement cmdwin as a normal buffer+window. All of the cmdwin contortions (in both core, and innocent plugins) exist literally only to support "inception": recursive cmdwin-in-cmdline-things, like `<c-r>=`, `/`, search-during-substitute, `:input()`, etc. So we just won't support that (though I have a potential plan for that later, which I call "modal parking lot"). The benefit is that plugins, and core, no longer have to care about cmdwin. BONUS: - mouse-drag on vertical separators works (it only worked for horizontal/statusline before) - inccommand-in-cmdwin now works correctly, for free (thus don't need #40077). POTENTIAL FOLLOWUPS - Drop `CHECK_CMDWIN` ("E11: Invalid in command-line window"), allow chaos. - Unify `BUFLOCK_OK` / `LOCK_OK` ? DESIGN: - Eliminate lots of C globals, `EX_CMDWIN`, etc. - `text_locked()` no longer reports true for cmdwin. - cmdwin = a normal window with 'winfixbuf', 'bufhidden=wipe', 'buftype=nofile'. Invariants come from those options rather than special cases throughout the codebase. - `nv_record` for q:/q//q? calls Lua `nlua_call_vimfn("vim._core.cmdwin", …)`. No `K_CMDWIN` / cmdline-reader detour. - `cedit_key` (`c_CTRL-F`) schedules a deferred event that calls `vim._core.cmdwin.open(type, content, pos)` and returns `Ctrl_C` so the in-flight cmdline cancels. Reader state is not serialized; instead the captured `(type, line, col)` is replayed via `nvim_feedkeys(type..line.."<CR>", "nt", …)` after user confirms. - On confirm/cancel: `<CR>` / `<C-C>` calls into Lua which closes the window and re-feeds the cmdline. BREAKING CHANGES: - Expression-register cmdline (`<C-R>=` from insert-mode) no longer supports cmdwin. Same applies to `input()` / `inputlist()` (already covered by `text_locked`). - Usage of cmdwin in macros/mappings will probably break (assuming they ever worked).
* fix(cmdline): avoid redraw loop after wrapped line #40240Sam Reynoso2026-06-19
| | | | | | | | | | | Problem: A wrapped command line and screen width may be redrawn repeatedly after calls to `redrawstatus` from lua. Solution: redrawcmd() redraws the command line, but msg_clr_eos() may invalidate cmdline_was_last_drawn during the redraw process. Restore cmdline_was_last_drawn when redrawcmd() completes. Co-authored-by: Sam Reynoso <sam@codeoutpost.com> Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
* vim-patch:9.2.0346: Wrong cursor position when entering command line window ↵zeertzjq2026-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | (#39072) Problem: Wrong cursor position when entering command line window Solution: Add check_cursor() command to verify the cursor position (Hirohito Higashi). When opening the command-line window with CTRL-F after typing a command that fills the screen width, the cursor was placed past the end of the line. Add check_cursor() after setting State to MODE_NORMAL so the cursor is adjusted to the last character. Also fix the cmdwin prefix character (e.g. ':') being drawn on wrapped continuation rows. Draw an empty space instead so that the text alignment is preserved. closes: vim/vim#19964 https://github.com/vim/vim/commit/c4fe1e958a2051d443abe072c8a5366a887da9b3 Cherry-pick Test_wildmenu_pum() changes from patch 9.1.1995. Co-authored-by: Hirohito Higashi <h.east.727@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(cmdline): avoid Ex-mode NULL cmdline_block event #39043luukvbaal2026-04-14
| | | | | | Problem: Attempting to emit cmdline_block event with NULL cmdbuff after <C-\><C-N> in Ex-mode. Solution: Don't emit cmdline_block event when cmdbuff is NULL.
* docs: news #38464Justin M. Keyes2026-03-28
|
* fix(messages): spurious newline with --headless + cmdheight=0 #38494kq2026-03-27
| | | | | | | | | | | | | | | Problem: When running nvim in headless mode with `cmdheight=0`, an extra newline is prepended to output (eg. `nvim --clean --cmd 'set cmdheight=0' --headless -c 'echo 1 | q' ` prints `\n1` instead of `1`), because `!ui_has(kUIMessages)` is always true in headless mode, causing `p_ch == 0` in `msg_start()` to unconditionally trigger `msg_putchar('\n')` which writes a newline to stdout. Solution: When in headless printf mode with `p_ch == 0` and no prior output on the current line, call `msg_puts_display("\n", ...)` directly instead of `msg_putchar('\n')`, so the grid is still updated for correct screen positioning but no newline is written to stdout.
* fix(cmdline): cmdline_block events for :lua debug.debug() #38171luukvbaal2026-03-06
| | | | | Problem: :lua debug.debug() is missing cmdline_block events. Solution: Emit cmdline_block_show/append/hide events for :lua debug.debug().
* fix(ui): cmdline_block events for exmode #37751luukvbaal2026-02-06
| | | | | Problem: Exmode is missing cmdline_block events. Solution: Emit cmdline_block_show/append when executing a cmdline during exmode. Emit cmdline_block_hide when leaving exmode.
* fix(cmdline): fix inconsistent behavior with ext_popupmenu (#35688)zeertzjq2025-09-09
|
* test: add tests for #20348zeertzjq2025-09-08
|
* fix(ui): proper event ordering for nested cmdline_block events (#35344)luukvbaal2025-08-20
| | | | | Problem: Wrong event order for nested cmdline in a conditional cmdline_block. Solution: Emit all but the first cmdline_block event immediately after getting the next command, before executing it.
* fix(ui): check for cmdline mode properly (#35202)zeertzjq2025-08-07
|
* 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().
* fix(messages): recognize cmdline one_key/number prompt State (#34206)luukvbaal2025-06-09
| | | | | | | | | | Problem: Since 48e2a736, prompt messages are handled by an actual active cmdline, resulting in `State` no longer being equal to `MODE_CONFIRM` which is used in some places. E.g. to specify the current `mode()` or to re-emit a confirm message. Solution: Replace `MODE_CONFIRM` with a new `MODE_CMDLINE` sub-mode when `ccline.one_key/mouse_used` is set. Use it to avoid clearing mouse_used prompt messages, and to re-emit one_key messages (when ext_messages is inactive, for which this is unnecessary).
* feat(messages): hl-StderrMsg, hl-StdoutMsg #33429Sathya Pramodh2025-05-02
| | | | | | | | | Problem: stderr messages from executing ":!cmd" show up with highlight hl-ErrorMsg. But some shell utilites use stderr for debug logging, progress updates, etc. Solution: Highlight shell command outputs hl-StderrMsg and hl-StdoutMsg.
* fix(cmdline): avoid empty @: register after :<CR> (#33126)luukvbaal2025-03-28
| | | Fix https://github.com/neovim/neovim/issues/33125
* fix(cmdline): empty ext_cmdline block events for :<CR> #33118luukvbaal2025-03-28
| | | | | Problem: An ext_cmdline block event that should be empty after :<CR> re-emits the previous cmdline. Solution: Clear `last_cmdline` even when `new_last_cmdline == NULL`.
* vim-patch:9.1.1243: diff mode is lacking for changes within lineszeertzjq2025-03-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Diff mode's inline highlighting is lackluster. It only performs a line-by-line comparison, and calculates a single shortest range within a line that could encompass all the changes. In lines with multiple changes, or those that span multiple lines, this approach tends to end up highlighting much more than necessary. Solution: Implement new inline highlighting modes by doing per-character or per-word diff within the diff block, and highlight only the relevant parts, add "inline:simple" to the defaults (which is the old behaviour) This change introduces a new diffopt option "inline:<type>". Setting to "none" will disable all inline highlighting, "simple" (the default) will use the old behavior, "char" / "word" will perform a character/word-wise diff of the texts within each diff block and only highlight the differences. The new char/word inline diff only use the internal xdiff, and will respect diff options such as algorithm choice, icase, and misc iwhite options. indent-heuristics is always on to perform better sliding. For character highlight, a post-process of the diff results is first applied before we show the highlight. This is because a naive diff will create a result with a lot of small diff chunks and gaps, due to the repetitive nature of individual characters. The post-process is a heuristic-based refinement that attempts to merge adjacent diff blocks if they are separated by a short gap (1-3 characters), and can be further tuned in the future for better results. This process results in more characters than necessary being highlighted but overall less visual noise. For word highlight, always use first buffer's iskeyword definition. Otherwise if each buffer has different iskeyword settings we would not be able to group words properly. The char/word diffing is always per-diff block, not per line, meaning that changes that span multiple lines will show up correctly. Added/removed newlines are not shown by default, but if the user has 'list' set (with "eol" listchar defined), the eol character will be be highlighted correctly for the specific newline characters. Also, add a new "DiffTextAdd" highlight group linked to "DiffText" by default. It allows color schemes to use different colors for texts that have been added within a line versus modified. This doesn't interact with linematch perfectly currently. The linematch feature splits up diff blocks into multiple smaller blocks for better visual matching, which makes inline highlight less useful especially for multi-line change (e.g. a line is broken into two lines). This could be addressed in the future. As a side change, this also removes the bounds checking introduced to diff_read() as they were added to mask existing logic bugs that were properly fixed in vim/vim#16768. closes: vim/vim#16881 https://github.com/vim/vim/commit/9943d4790e42721a6777da9e12637aa595ba4965 Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
* fix(ui): wincmd _ should not increase 'cmdheight' above 0 (#33056)luukvbaal2025-03-27
|
* fix(cmdline): ext_cmdline block events for conditionalsLuuk van Baal2025-03-15
| | | | | | Problem: No block events emitted with ext_cmdline for :if, :while, :try etc. Solution: Emit cmdline block events; store the indent level of the previous cmdline and whether a block event was emitted.
* feat(diagnostic): virtual_lines #31959Maria José Solano2025-01-26
|
* fix(editor): avoid scrolling :substitute confirm message #32149luukvbaal2025-01-22
| | | Regression from 48e2a73.
* fix(cmdline): always show cmdline when it is a prompt #31866luukvbaal2025-01-05
| | | Cmdline prompts should ignore `cmd_silent`.
* feat(ui): more intuitive :substitute confirm prompt #31787luukvbaal2025-01-02
| | | | Problem: Unknown key mappings listed in substitute confirm message. Solution: Include hints as to what the key mappings do.
* feat(ui)!: emit prompt "messages" as cmdline events #31525luukvbaal2025-01-02
| | | | | | | Problem: Prompts are emitted as messages events, where cmdline events are more appropriate. The user input is also emitted as message events in fast context, so cannot be displayed with vim.ui_attach(). Solution: Prompt for user input through cmdline prompts.
* 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.
* 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.
* refactor(tests): use more global highlight definitionsbfredl2024-11-11
|
* feat(api): add nvim__redraw for more granular redrawingLuuk van Baal2024-05-02
| | | | | | | | | | | Experimental and subject to future changes. Add a way to redraw certain elements that are not redrawn while Nvim is waiting for input, or currently have no API to do so. This API covers all that can be done with the :redraw* commands, in addition to the following new features: - Immediately move the cursor to a (non-current) window. - Target a specific window or buffer to mark for redraw. - Mark a buffer range for redraw (replaces nvim__buf_redraw_range()). - Redraw the 'statuscolumn'.
* 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.
* Merge pull request #27872 from luukvbaal/cmdheightbfredl2024-04-21
|\ | | | | fix(ui): don't force 'cmdheight' to zero with ext_messages
| * fix(ui): don't force 'cmdheight' to zero with ext_messagesLuuk van Baal2024-04-20
| | | | | | | | Remove remaining code that prevents non-zero 'cmdheight' with ext_messages.
* | fix(api): do not update grid position in nvim_win_set_cursor (#28235)luukvbaal2024-04-21
|/ | | | Revert commit c971f538ab87b537ae4c97bd44167661c5691a2d. Forcing grid cursor position will need a new API like originally proposed in #27858.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* vim-patch:9.0.0581: adding a character for incsearch fails at end of linezeertzjq2024-04-03
| | | | | | | | | Problem: Adding a character for incsearch fails at end of line. Solution: Only check cursor line number. https://github.com/vim/vim/commit/d4566c14e71c55dcef05fb34ea94eba835831527 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(tests): use new global defaults instead of set_default_attr_idsbfredl2024-03-26
| | | | This will be done in batches.
* fix(ui): ext_cmdline should not move cursor to curwinLuuk van Baal2024-03-15
| | | | | | | | | | | Problem: The ext_cmdline cursor position on the screen seems to rely on an implicit assumption that the event listener implements a cmdline window that is made the current window which is problematic (e.g. breaks 'incsearch' in the actual current window). Solution: Remove this assumption and allow nvim_win_set_cursor() to move the cursor on the screen to a non-current window (previous commit).
* vim-patch:9.1.0106: Visual highlight hard to read with 'termguicolors'zeertzjq2024-02-15
| | | | | | | | | | | | | | | Problem: Visual highlight hard to read with 'termguicolors' (Maxim Kim) Solution: Set Visual GUI foreground to black (with background=light) and lightgrey (with background=dark) (Maxim Kim) fixes: vim/vim#14024 closes: vim/vim#14025 https://github.com/vim/vim/commit/34e4a05d02a016fe230495be8f6c60ddd56f9567 Co-authored-by: Maxim Kim <habamax@gmail.com>
* test: use integers for API Buffer/Window/Tabpage EXT typesLewis Russell2024-01-16
|
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: typing for helpers.methsLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|