-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Bug
Copy link
Labels
apilibnvim, Nvim RPC APIlibnvim, Nvim RPC APIhas:reproissue contains minimal reproducing stepsissue contains minimal reproducing steps
Milestone
Description
Problem
When editing a buffer via search-and-replace, the on_bytes callback given to nvim_buf_attach seems to be called with the old buffer contents, making it impossible to get the new text.
Steps to reproduce
- create this
minimal.lua:
vim.api.nvim_buf_set_lines(0, 0, -1, false, { "Hello" })
local buffer_lines = {}
vim.api.nvim_buf_attach(0, false, {
on_bytes = function()
buffer_lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
end
})
vim.cmd("s/llo/y")
-- 💥 buffer_lines is { "Hello" }.
assert(
vim.deep_equal(buffer_lines, { "Hey" }),
("buffer_lines: %s"):format(vim.inspect(buffer_lines))
)- run
nvim --clean -u minimal.lua
Expected behavior
When called in on_bytes, vim.api.nvim_buf_get_{text|lines} returns the new contents .
Nvim version (nvim -v)
NVIM v0.12.0-nightly+a04c73c
Vim (not Nvim) behaves the same?
N/A
Operating system/version
macOS 15.7
Terminal name/version
Ghostty
$TERM environment variable
ghostty
Installation
Nix flake
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
apilibnvim, Nvim RPC APIlibnvim, Nvim RPC APIhas:reproissue contains minimal reproducing stepsissue contains minimal reproducing steps