Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvim_buf_set_text resets changelist to 0 #28618

Open
xiyaowong opened this issue May 3, 2024 · 2 comments
Open

nvim_buf_set_text resets changelist to 0 #28618

xiyaowong opened this issue May 3, 2024 · 2 comments
Labels
api libnvim, Nvim RPC API bug issues reporting wrong behavior

Comments

@xiyaowong
Copy link

Problem

Video:

changelist.mp4

Steps to reproduce

test.lua

local api = vim.api

vim.opt.showmode = false

local c = 'a'
local function append_first_line()
  local col = #api.nvim_buf_get_lines(0, 0, 1, true)[1]
  api.nvim_buf_set_text(0, 0, col, 0, col, { c })
  c = c == 'a' and 'b' or 'a'
end

local timer = vim.loop.new_timer()
timer:start(
  500,
  500,
  vim.schedule_wrap(function()
    if api.nvim_get_mode().mode ~= 'i' then
      append_first_line()
    end
  end)
)

vim.cmd "au TextChanged,TextChangedI * echo getchangelist()"
  1. nvim --clean -u ./test.lua
  2. See the output changelist

Expected behavior

nvim_buf_set_text should not reset changelist to 0

Neovim version (nvim -v)

NVIM v0.9.5

Vim (not Nvim) behaves the same?

not sure

Operating system/version

Windows 11

Terminal name/version

Windows Terminal

$TERM environment variable

Installation

scoop

@xiyaowong xiyaowong added the bug issues reporting wrong behavior label May 3, 2024
@glepnir glepnir added the api libnvim, Nvim RPC API label May 3, 2024
@justinmk
Copy link
Member

justinmk commented May 3, 2024

Can you try the development version? The Releases page has pre-built archives for Linux/Windows/macOS.

I see a bunch of changes in the changelist, in 0.10 Confirmed with nvim --clean test.lua (sourcing the script with :%lua has different behavior)

@justinmk justinmk added the needs:response waiting for reply from the author label May 3, 2024
@xiyaowong
Copy link
Author

xiyaowong commented May 3, 2024

Tested the nightly version, the problem still exists

NVIM v0.10.0-dev-3070+gcf9f002f3
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068

@github-actions github-actions bot removed the needs:response waiting for reply from the author label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api libnvim, Nvim RPC API bug issues reporting wrong behavior
Projects
None yet
Development

No branches or pull requests

3 participants