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

on_bytes args of nvim_buf_attach are different when using o and A<Enter> #25966

Closed
lucario387 opened this issue Nov 10, 2023 · 2 comments
Closed
Labels
bug issues reporting wrong behavior

Comments

@lucario387
Copy link
Contributor

lucario387 commented Nov 10, 2023

Problem

This is possibly the same as #25822

Using o, the args passed to on_bytes of nvim_buf_attach is different from when using A<Enter>

Steps to reproduce

  • Have a test.lua file as such
vim.api.nvim_create_autocmd("BufEnter", {
  callback = function(args)
    vim.api.nvim_buf_attach(args.buf, true, {
      on_bytes = function(_, _, _, start_row, _, _, old_end_row, _, _, new_end_row, _, _)
        print(start_row, old_end_row, new_end_row)
      end
    })
  end
})
  • nvim --clean -u test.lua test.foo and do o. We get 1 0 1
  • nvim --clean -u test.lua test.foo and do A<Enter>. We get 0 0 1

Expected behavior

They should both be 0 0 1, or be more consistent.

Neovim version (nvim -v)

NVIM v0.10.0-dev-43b0e2752

Vim (not Nvim) behaves the same?

unsure

Operating system/version

Linux 6.6.1

Terminal name/version

kitty 0.31.0

$TERM environment variable

xterm-kitty

Installation

Build from source

@lucario387 lucario387 added the bug issues reporting wrong behavior label Nov 10, 2023
@lucario387
Copy link
Contributor Author

lucario387 commented Nov 10, 2023

This is also why #25822 was incorrect, I'd assume.

As on_bytes of foldexpr was relying on nvim_buf_attach's on_bytes to return the correct start row, old row and new row, but pressing O means the start row is the same as the new index, meaning the row range is one-off from the correct one. This can also be confirmed by instead doing A<Enter>, and the foldcolumn is correctly updated

@lucario387 lucario387 changed the title on_bytes args of nvim_buf_attach are different when using O and A<Enter> on_bytes args of nvim_buf_attach are different when using o and A<Enter> Nov 10, 2023
@tomtomjhj
Copy link
Sponsor Contributor

seems to be fixed by #26364.

@zeertzjq zeertzjq closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior
Projects
None yet
Development

No branches or pull requests

3 participants