bloznelis / before.nvim

Jump to the last edit in Neovim
MIT License
114 stars 4 forks source link

Bug: Unable to jump if a change is on the last line #2

Closed ColinKennedy closed 6 months ago

ColinKennedy commented 6 months ago

If you edit the last line of a buffer, before.nvim doesn't record the change on the last line. I make 3 edits with the last edit on the last line of the buffer but before.nvim only cycles between the first 2 edits.

Demo

https://github.com/bloznelis/before.nvim/assets/10103049/826f4af3-d6fc-40d5-8521-946faaf4fab9

Reproduction

reproduction.lua file ```lua -- DO NOT change the paths and don't remove the colorscheme local root = vim.fn.fnamemodify("./.repro", ":p") for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name end local lazypath = root .. "/plugins/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, }) end local lazypath = root .. "/plugins/lazy.nvim" vim.opt.runtimepath:prepend(lazypath) local plugins = { { "bloznelis/before.nvim", config = function() local before = require('before') before.setup() vim.keymap.set( "n", "[c", function() require("before").jump_to_last_edit() end ) vim.keymap.set( "n", "]c", function() require("before").jump_to_next_edit() end ) end, }, } require("lazy").setup(plugins, { root = root .. "/plugins" }) ```
ColinKennedy commented 6 months ago

By the way it seems to be the case for first lines, as well. It doesn't jump to any change on the first line, that I can see

bloznelis commented 6 months ago

By the way it seems to be the case for first lines, as well. It doesn't jump to any change on the first line, that I can see

Ok, sounds like a problem with boundaries checking. A classic off-by-one error?