aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/prompt_buffer_spec.lua
Commit message (Collapse)AuthorAge
* feat(editor): undo restores cursor position #41520Justin M. Keyes2026-08-27
| | | | | | | | | | | | | | | | | | Problem: Undo places the cursor wherever the cursor happened to sit at "save time" (`uh_cursor` is sampled lazily on the first change). Examples: - `i` preserves, but `a` does not - `diw`, `atest<Esc>`, `d^` abandon the original position - `D`, `o` restore it (by accident). Solution: `composite` tracks the pending atom (and its `origin`) across frames. A `stuffed` continuation frame inherits the `origin` + prepped redo. Store `origin` info in the undo header, so undo can restore it. - Not for a mid-command undo break (i_CTRL-G_u). - Undoing a mapping restores where the mapping started (which technically may be different than where the "edit" started).
* 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`.
* feat(prompt): support 'scrollback' option in prompt-buffers #39793Tomas Slusny2026-05-16
| | | | | | | | | | | | | | Problem: There is a lot of overlap between terminal and prompt buffer, but no easy way to limit the number of lines kept above the prompt to prevent performance and other issues. This is desirable for both example use cases in current documentation, chat UI and repl/shell plugins. Solution: Use existing 'scrollback' option to limit prompt-buffer lines as well. Signed-off-by: Tomas Slusny <slusnucky@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* fix(prompt): handle multi-element lists in prompt_appendbuf #39550Tomas Slusny2026-05-12
| | | | | | | | | | | | Problem: When using prompt_appendbuf with multi-element list, the first item is concated and rest replace the prompt instead of inserting the lines before the prompt. Solution: Concat first element with replace_buf and insert the rest of the list with set_buffer_lines. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
* refactor(test): drop deprecated exc_exec #39242Justin M. Keyes2026-04-20
|
* feat(prompt): prompt_appendbuf() appends to prompt buffer #37763Shadman2026-03-27
| | | | | | | | | | | Problem: Currently, we recommend always inserting text above prompt-line in prompt-buffer. This can be done using the `:` mark. However, although we recommend it this way it can sometimes get confusing how to do it best. Solution: Provide an api to append text to prompt buffer. This is a common use-case for things using prompt-buffer.
* fix(prompt): don't implicitly set 'modified' #38118Willaaaaaaa2026-03-11
| | | | | | | | | | | | | Problem: In aec3d7915c55fc0b7dc73f6186cf0ae45d416d33 Vim changed prompt-buffers to respect 'modified' so the termdebug plugin can "control closing the window". But for most use-cases (REPL, shell, AI "chat", …), prompt-buffers are in practice always "modified", and no way to "save" them, so *implicitly* setting 'modified' is noisy and annoying. Solution: Don't implicitly set 'modified' when a prompt-buffer is updated. Plugins/users can still explicitly set 'modified', which will then trigger the "E37: No write since last change" warning.
* fix(prompt): clear undo when changing/appending promptSean Dewar2026-02-17
| | | | | | | | | | | | | | | Problem: undoing after the prompt is changed breaks it (and causes init_prompt to abort it and append a new one), as the undo history contains the old prompt. Solution: like submitting, clear the undo buffer. Don't do it in init_prompt if the line was empty; that may not result in a new prompt, and causes commands like "S" to lose the history. As u_save, etc. wasn't being called by prompt_setprompt, undoing after it fixes the prompt usually gave undesirable results anyway. Remove the added undo_spec.lua test, as its approach no longer works as a repro, and finding a new one seems fiddly.
* fix(prompt): prompt_setprompt cursor col adjustmentSean Dewar2026-02-17
| | | | | | | | Problem: prompt_setprompt adjusted cursor col may be negative (<=0 when 1-based), and doesn't check the col of ': Solution: avoid negative col and adjust correctly if ': col differs from old prompt's length.
* fix(prompt): prompt_setprompt with unloaded buffer, ': with lnum 0Sean Dewar2026-02-17
| | | | | | | Problem: prompt_setprompt memory leak/other issues when fixing prompt line for unloaded buffer, or when ': line number is zero. Solution: don't fix prompt line for unloaded buffer. Clamp ': lnum above zero.
* fix(prompt): wrong cursor col after prompt_setprompt, no on_linesSean Dewar2026-02-15
| | | | | | | | | | | | | | Problem: prompt_setprompt calls coladvance with a byte column, but it expects a screen column. on_lines buffer-updates aren't fired when fixing the prompt line. Solution: don't use coladvance. Call changed_lines, which also simplifies the redraw logic. (and calls changed_cline_bef_curs if needed; added test checks this) Unlike https://github.com/neovim/neovim/pull/37743/changes#r2775398744, this means &modified is set by prompt_setprompt if it fixes the prompt line. Not setting &modified is inconsistent anyway -- even init_prompt sets it if it fixes the prompt line.
* vim-patch:9.2.0004: Changing hidden prompt buffer cancels ↵zeertzjq2026-02-15
| | | | | | | | | | | | :startinsert/:stopinsert (#37881) Problem: Changing hidden prompt buffer cancels :startinsert/:stopinsert (after 9.0.1439). Solution: Don't change mode for a prompt buffer in an autocommand window (zeertzjq). closes: vim/vim#19410 https://github.com/vim/vim/commit/8b81a6b6e1d514cf0544e0c6d12412ba813564b0
* fix(prompt): prompt_setprompt sets cursor col unnecessarilySean Dewar2026-02-15
| | | | | | | Problem: prompt_setprompt adjusts the cursor's column number even when it's not on the prompt's line. Solution: only adjust when on the prompt's line.
* fix(prompt): ml_get error with invalid ': lnumSean Dewar2026-02-15
| | | | | | Problem: internal error E315 in init_prompt if ': has an invalid line number. Solution: clamp the line number.
* fix(prompt): heap-buffer-overflows with invalid ': colSean Dewar2026-02-15
| | | | | | | | | Problem: heap-buffer-overflow in init_prompt and prompt_setprompt if ': mark has an invalid column number. Solution: consider an out-of-bounds column number as a missing prompt. Remove the check for NULL for old_line, as ml_get_buf can't return NULL.
* fix(prompt): heap-buffer-overflow in prompt_setpromptSean Dewar2026-02-15
| | | | | | | | | Problem: prompt_setprompt may check the wrong buffer, which can lead to a heap-buffer-overflow. Solution: don't use curbuf. Also replace all kCallbackNone initializers with CALLBACK_INIT.
* feat(prompt): plugins can update prompt during user input #37743Shadman2026-02-14
| | | | | | | | | | | Problem: Currently, if prompt gets changed during user-input with prompt_setprompt() it only gets reflected in next prompt. And that behavior is not also consistent. If user re-enters insert mode then the user input gets discarded and a new prompt gets created with the new prompt. Solution: Handle prompt_setprompt eagerly. Update the prompt display, preserve user input.
* fix(prompt): ensure prompt-mark col gets reseted properly #37669Shadman2026-02-03
| | | | | | | problem: currently when empty string is set as prompt the prompt-mark column doesn't update. solution: ensure the column is reset to 0 when starting prompt buffer and before creating a new prompt after prompt-callback.
* fix(prompt): also store column info in ': mark #36194Shadman2026-01-30
| | | | | | | | Problem: Currently, : mark is set in start of prompt-line. But more relevant location is where the user text starts. Solution: Store and update column info on ': just like the line info
* fix(prompt): wrong cursor position with cursor keys (#36196)Shadman2025-11-08
| | | | | | | | | | | | | | | **Problem**: Currently, whenever user get's on prompt-text area we move the user to end of user-input area. As a result when left/c-left,home keys are triggered at start of user-input the cursor get's placed at end of user-input. But this behavior can be jarring and unintuitive also it's different from previous behavior where it'd just stay at start of input-area. Also, previously when insert-mode was triggered in prompt-text with n_a for example then cursor was placed at start of user-input area not at the end. So, that behavior was also broken. **Solution:** Restore previous behavior. Don't force user to end of user-input when entering insert-mode from readonly section.
* test: fix prompt_buffer_spec flakiness (#35838)Shadman2025-09-19
| | | Remove incorrect use of source_script().
* docs: small fixes (#35791)zeertzjq2025-09-16
| | | | | | | | | | | | | | | | | | | | | Close #34938 Close #35030 Close #35233 Close #35259 Close #35290 Close #35433 Close #35541 Close #35766 Close #35792 Co-authored-by: huylg <45591413+huylg@users.noreply.github.com> Co-authored-by: Jason Del Ponte <961963+jasdel@users.noreply.github.com> Co-authored-by: sooriya <74165167+thuvasooriya@users.noreply.github.com> Co-authored-by: Andrew Braxton <andrewcbraxton@gmail.com> Co-authored-by: Enric Calabuig <enric.calabuig@gmail.com> Co-authored-by: Augusto César Dias <augusto.c.dias@gmail.com> Co-authored-by: David Sierra DiazGranados <davidsierradz@gmail.com> Co-authored-by: Stepan Nikitin <90522882+vectravox@users.noreply.github.com> Co-authored-by: Emilien Breton <bricktech2000@gmail.com>
* fix(prompt_buffer): plugins can't set `':` mark #35624Shadman2025-09-08
| | | | | | | | | | Problem: Currently, prompt_buffer manages `:` mark by itself and exposes it read-only mark. However when it fails there can be no mitigation made by plugins. The `:` mark should act like a regular marks and be modifiable. Solution: Allow plugins to set `:` mark.
* fix(prompt): cursor on prompt line, disallow ":edit" #34736Shadman2025-07-29
| | | | * fix: ensure :edit can not be use on prompt buffer * fix: starting editing on prompt-line doesn't put cursor at the end
* fix(prompt): prompt mark not placed after text edits correctly #34671Shadman2025-06-30
|
* feat(prompt): prompt_getinput() gets current input #34491Shadman2025-06-24
| | | | | | | | | | Problem: Not easy to get user-input in prompt-buffer before the user submits the input. Under the current system user/plugin needs to read the buffer contents, figure out where the prompt is, then extract the text. Solution: - Add prompt_getinput(). - Extract prompt text extraction logic to a separate function
* fix(prompt): "%" prefix repeated on newlines with formatoptions+=r #34584Shadman2025-06-24
| | | | | | | | | | Problem: With `formatoptions+=r`, the prompt prefix "%" is treated as comment-start (because of global default 'comments' option contains "%"), so it gets added to the start of the line when a new line is input in a prompt. Solution: Unset the 'comments' option in prompt buffers by default.
* test(prompt): nvim_paste in prompt buffer #34583Shadman2025-06-20
|
* docs: api, miscJustin M. Keyes2025-06-18
|
* feat(prompt): multiline prompt input #33371Shadman2025-06-17
| | | | | | | | | | | | | | Problem: Cannot enter multiline prompts in a buftype=prompt buffer. Solution: - Support shift+enter (`<s-enter>`) to start a new line in the prompt. - Pasting multiline text via OS paste, clipboard, "xp, etc. - A/I in editable region works as usual. - i/a/A/I outside of editable region moves cursor to end of current prompt. - Support undo/redo in prompt buffer. - Support o/O in prompt buffer. - Expose prompt location as `':` mark.
* 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.
* 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.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* 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)
* vim-patch:9.1.0040: issue with prompt buffer and hidden buffer (#27071)zeertzjq2024-01-18
| | | | | | | | | | | | Problem: Modifying a hidden buffer still interferes with prompt buffer mode changes. Solution: Save and restore b_prompt_insert. (zeertzjq) closes: vim/vim#13875 Modifying hidden buffer still interferes with prompt buffer mode changes https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69
* vim-patch:9.1.0033: Insert mode not stopped if closing prompt buffer ↵zeertzjq2024-01-17
| | | | | | | | | | | | modifies hidden buffer (#27051) Problem: Insert mode not stopped if an autocommand modifies a hidden buffer while closing a prompt buffer. Solution: Don't set b_prompt_insert if stop_insert_mode is already set. (zeertzjq) closes: vim/vim#13872 https://github.com/vim/vim/commit/96958366ad6159efe708b694055320ed19357e61
* 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
|
* 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
* vim-patch:9.0.1443: ending Insert mode when accessing a hidden prompt buffer ↵zeertzjq2023-04-10
| | | | | | | | | | (#22984) Problem: Ending Insert mode when accessing a hidden prompt buffer. Solution: Don't stop Insert mode when it was active before. (closes vim/vim#12237) https://github.com/vim/vim/commit/05a627c3d4e42a18f76c14828d68ee4747118211 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.1439: start Insert mode when accessing a hidden prompt buffer ↵zeertzjq2023-04-03
| | | | | | | | | | | | | (#22867) Problem: Start Insert mode when accessing a hidden prompt buffer. Solution: Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst, closes vim/vim#12148, closes vim/vim#12147) https://github.com/vim/vim/commit/cde8de034524d00aba4ff4142e658baff511e12d Cherry-pick test_prompt_buffer.vim changes from patch 9.0.0631. Co-authored-by: orbital <orbital@holgerines.de>
* test(legacy/prompt_buffer_spec): align script with oldtest more (#22354)zeertzjq2023-02-21
|
* fix(tests): fix some screen.lua warningsbfredl2022-05-21
|
* vim-patch:8.2.3671: restarting Insert mode in prompt buffer too oftenSean Dewar2021-12-07
| | | | | | | | | | | | | | | Problem: Restarting Insert mode in prompt buffer too often when a callback switches windows and comes back. (Sean Dewar) Solution: Do not set "restart_edit" when already in Insert mode. https://github.com/vim/vim/commit/34c20ff85b87be587ea5d0398812441b502ee6a5 As Test_prompt_switch_windows is skipped, implement it in prompt_buffer_spec. Replace the 50ms term_wait calls with poke_eventloop (test seems to work anyway without them, so maybe they're not required?) The new test does include a duplicate screen test that may generate a "screen test succeeded immediately" warning, but this is done to match the Vim test.
* test(prompt_buffer_spec): include changes from v8.1.1984Sean Dewar2021-12-07
| | | | | | | | I already ported v8.1.1984 previously, but hadn't updated prompt_buffer_spec to match test_prompt_buffer (which we have but due to Vim features such as term_sendkeys it's mostly skipped). Required for v8.2.3671.
* vim-patch:8.2.2014: using CTRL-O in a prompt buffer moves cursor to startSean Dewar2021-12-07
| | | | | | | | Problem: Using CTRL-O in a prompt buffer moves cursor to start of the line. Solution: Do not move the cursor when restarting edit. (closes vim/vim#7330) https://github.com/vim/vim/commit/ee8b787bcd15f63a938243770065e704c9b5c85f Test_prompt_editing is skipped, so edit the Lua test in prompt_buffer_spec.
* vim-patch:8.2.1781: writing to prompt buffer interferes with insert modeSean Dewar2021-12-07
| | | | | | | | | | | Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) https://github.com/vim/vim/commit/4537bcc88956f86267c25edf8008e0dbde598652 Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines).
* vim-patch:8.1.0092: prompt buffer test failserw72020-02-12
| | | | | | | Problem: Prompt buffer test fails. Solution: Set 'nomodified' before closing the window. (Ozaki Kiichi, closes vim/vim#3051 https://github.com/vim/vim/commit/71ef1ba5e996f34d3e0acbe1d89c4c6bfa5e98ba