summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/lua/buffer_updates_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-15refactor: update usages of deprecated "buffer" param #39089Justin M. Keyes1
2026-04-15test: replace busted with local harnessLewis Russell1
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
2026-03-12docs: use "ev" convention in event-handlersJustin M. Keyes1
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.
2026-02-15fix(prompt): wrong changed lnum in init_promptSean Dewar1
Problem: if init_prompt replaces the prompt line at the ': mark, it calls inserted_bytes with the wrong lnum. Solution: use the correct lnum. Call appended_lines_mark instead when appending the prompt at the end.
2026-02-15fix(prompt): prompt_setprompt does not adjust extmarks, no on_bytesSean Dewar1
Problem: prompt_setprompt does not adjust extmarks or trigger on_bytes buffer-updates when fixing the prompt line. Solution: adjust them, trigger on_bytes. Notably, hides extmarks when replacing the entire line (and clearing user input). Otherwise, when just replacing the prompt text, hides extmarks there, but moves those after (in the user input area) to the correct spot.
2026-02-15fix(prompt): wrong cursor col after prompt_setprompt, no on_linesSean Dewar1
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.
2026-01-08test(buffer_updates_spec): move on_detach tests to its block (#37297)zeertzjq1
2025-11-20fix(api): on_bytes gets stale data on :substitute #36487Riccardo Mazzarini1
Problem: `extmark_splice()` was being called before `ml_replace()`, which caused the on_bytes callback to be invoked with the old buffer text instead of the new text. Solution: store metadata for each match in a growing array, call `ml_replace()` once to update the buffer, then call `extmark_splice()` once per match. Closes https://github.com/neovim/neovim/issues/36370.
2025-08-24docs: misc #35459Justin M. Keyes1
2025-08-17fix(api): on_detach consistently before buf_freeall autocmdsSean Dewar1
Problem: on_detach may be called after buf_freeall and other important things, plus its textlock restrictions are insufficient. This can cause issues such as leaks, internal errors and crashes. Solution: disable buffer updates in buf_freeall, before autocommands (like the order after #35355 and when do_ecmd reloads a buffer). Don't do so in free_buffer_stuff; it's not safe to run user code there, and buf_freeall already runs before then; just free them to avoid leaks if buf_freeall autocommands registered more for some reason. Fixes #28084 Fixes #33967 Fixes #35116
2025-08-17fix(api,lsp): call on_detach before wiping out the buffer #35355Jaehwang Jung1
Problem: Buffer-updates on_detach callback is invoked before buf_freeall(), which deletes autocmds of the buffer (via apply_autocmds(EVENT_BUFWIPEOUT, ...)). Due to this, buffer-local autocmds executed in on_detach (e.g., LspDetach) are not actually invoked. Solution: Call buf_updates_unload() before buf_freeall().
2025-07-29fix(api): single-line visual block insert triggers extra on_lines #35098glepnir1
Problem: Visual block insert on a single line incorrectly triggers two on_lines callbacks - one for the correct line (0-indexed) and another for a non-existent additional line. Solution: Only call changed_lines() in block_insert() when additional lines beyond the first were actually modified (start.lnum < end.lnum).
2025-06-23fix(quickfix): use correct lnume when appending (#34611)glepnir1
Problem: ml_get error when updating quickfix buffer with nvim_buf_attach Solution: use correct lnume parameter in changed_lines for append mode Fix #34610
2025-06-17fix(api): buffer updates in quickfix buffer #31105glepnir1
Problem: Buffer events (specifically on_bytes callbacks) weren't triggered when the quickfix list was modified, preventing buffer change notifications. Solution: Add code to send both bytes and lines change notifications after quickfix buffer updates to properly trigger all attached callbacks.
2025-02-12fix(memline): don't check line count for closed memline #32403luukvbaal1
Problem: Error thrown when for invalid line number which may be accessed in an `on_detach` callback at which point line count is intentionally set to 0. Solution: Move empty memline check to before line number check.
2024-11-14fix(tests): needing two calls to setup a screen is cringebfredl1
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.
2024-09-21test: support upvalues in exec_luaLewis Russell1
2024-08-02test: allow exec_lua to handle functionsLewis Russell1
Problem: Tests have lots of exec_lua calls which input blocks of code provided as unformatted strings. Solution: Teach exec_lua how to handle functions.
2024-06-02test: add a test for #29119zeertzjq1
2024-04-23test: improve test conventionsdundargoc1
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.
2024-04-10refactor(test): inject after_each differentlyLewis Russell1
2024-04-10fix(prompt): emit change event for prompt newline (#28260)zeertzjq1
Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
2024-04-08test: improve test conventionsdundargoc1
Work on https://github.com/neovim/neovim/issues/27004.
2024-03-30fix(extmarks): splice earlier when opening new line (#28108)zeertzjq1
Related #26364 #26499 #26501 Fix #28107
2024-03-12vim-patch:8.2.4944: text properties are wrong after "cc" (#27821)zeertzjq1
Problem: Text properties are wrong after "cc". (Axel Forsman) Solution: Pass the deleted byte count to inserted_bytes(). (closes vim/vim#10412, closes vim/vim#7737, closes vim/vim#5763) https://github.com/vim/vim/commit/d0b1a09f44654bb5e29b09de1311845200f17d90 Co-authored-by: LemonBoy <thatlemon@gmail.com>
2024-03-11test: correct order of arguments to eq() (#27816)zeertzjq1
2024-01-13Merge pull request #26734 from bfredl/splitaroobfredl1
fix(buffer_updates): correct buffer updates when splitting empty line
2024-01-13fix(buffer_updates): correct buffer updates when splitting empty linebfredl1
fixes #11591
2024-01-12test: rename (meths, funcs) -> (api, fn)Lewis Russell1
2024-01-12test: typing for helpers.methsLewis Russell1
2024-01-12test: use vim.mpack and vim.uv directlyLewis Russell1
2024-01-03refactor: format test/*Justin M. Keyes1
2023-12-05fix(change): update fold after on_bytes (#26364)Jaehwang Jung1
Problem: With vim.treesitter.foldexpr, `o`-ing two lines above a folded region opens the fold. This does not happen with legacy foldexprs. For example, make a markdown file with the following text (without indentation), enable treesitter fold, and follow the instruction in the text. put cursor on this line and type zoo<Esc> initially folded, revealed by zo # then this fold will be opened initially folded, revealed by o<Esc> Analysis: * `o` updates folds first (done in `changed_lines`), evaluating foldexpr, and then invokes `on_bytes` (done in `extmark_splice`). * Treesitter fold allocates the foldinfo for added lines (`add_range`) on `on_bytes`. * Therefore, when treesitter foldexpr is invoked while running `o`, it sees outdated foldinfo. Solution: `extmark_splice`, and then `changed_lines`. This seems to be the standard order in other places, e.g., `nvim_buf_set_lines`.
2023-09-15fix: invoke changed_bytes when rewriting <Tab> char #25125Ilia Choly1
When tabstop and shiftwidth are not equal, tabs are inserted as individual spaces and then rewritten as tab characters in a second pass. That second pass did not call changed_bytes which resulted in events being omitted. Fixes #25092
2023-06-06fix(spell): splice extmarks on :spellrepall (#23929)zeertzjq1
2023-05-22test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value`Famiu Haque1
`nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
2023-05-21refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell1
Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-04-04test: replace lfs with luv and vim.fsdundargoc1
test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed.
2023-03-11fix(diff): trigger on_bytes only once after diffget/diffputJaehwang Jung1
Problem: The fix from b50ee4a8dc4306e4be78ac33fb74b21dc6be5538 may adjust extmark twice, triggering on_bytes callback twice. Solution: Don't let mark_adjust adjust extmark.
2023-03-09fix(buffer_updates): save and restore current window cursor (#16732)zeertzjq1
When a buffer update callback is called, textlock is active so buffer text cannot be changed, but cursor can still be moved. This can cause problems when the buffer update is in the middle of an operator, like the one mentioned in #16729. The solution is to save cursor position and restore it afterwards, like how cursor is saved and restored when evaluating an <expr> mapping.
2022-09-30docs: fix typos (#20394)dundargoc1
Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: smjonas <jonas.strittmatter@gmx.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-26fix!: make :undo! notify buffer update callbacks (#20344)zeertzjq1
When :undo! was introduced to Nvim the implementation of 'inccommand' preview callback hasn't been fully decided yet, so not notifying buffer update callbacks made sense for 'inccommand' preview callback in case it needs to undo the changes itself. Now it turns out that the undo-and-forget is done automatically for 'inccommand', so it doesn't make sense for :undo! to avoid notifying buffer update callbacks anymore.
2022-06-13Merge pull request #18931 from zeertzjq/regexp-num-escapedzeertzjq1
fix(substitute): subtract number of backslashes later
2022-06-12fix(buffer): disable buffer-updates before removing from window #18933zeertzjq1
There can be other places that access window buffer info (e.g. `tabpagebuflist()`), so checking `w_closing` in `win_findbuf()` doesn't solve the crash in all cases, and may also cause Nvim's behavior to diverge from Vim. Fix #14998
2022-06-12fix(substitute): subtract number of backslashes laterzeertzjq1
2022-04-02fix(extmarks): splice extmarks on accepting spellTony Chen1
2021-10-08fix(buffer_updates): handle :sort of already sorted bufferBjörn Linse1
2021-10-07fix(buffer_updates): cleanup test behaviorBjörn Linse1
2021-10-07fix(buffer_updates): make `lockmarks` not affect extmarks and buffer ↵Anton Adamansky1
updates. fixes #12861 Now mark_adjust() will trigger appropriate buf_updates_send_splice() called by extmark_adjust()
2021-10-07fix(buffer_updates): handle :delete of the very last line in bufferBjörn Linse1