-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
tracking issue: new incremental sync (luansnip, 'index out of range', undos) #16274
Comments
I'll look into this, and try to have it fixed by tonight. NB: the bad call is |
LuaSnip
null-ls had an issue caused by the removal of |
Great! Thanks. If you all need it a diffing algorithm you would need to be sure you are passing the same arguments as we rely on detailed information from the on_lines callback to get the true start/end range. |
The actual pre and post lines for the diff are:
With the info passed to the on_lines callback being:
As far as I can see, no change. The problematic thing is new_lastline and lastline ( -1) are out of the range which speaks to the buffer state captured when on_lines is invoked being out of sync with the info passed to on_lines. What concretely this means is the "shortcuts" I took to making the extremely efficient (basically we know exactly the line the diff occurs on ahead of time and only have to scan at most one line) cannot rely on the knowledge they are assuming to be accurate The options are Long-term: fix the internal undo tracking in neovim The old mechanism was a bit more robust (but still wrong) to firstline/lastline being incorrect for the current buf. |
hmm, is the same bug also visible in external buffer updates ( |
Copying a reproduction from a duplicate issue: mp.tex: \begin{document}
\section*{1}
\section*{1}
\section*{1}
\end{document}
Similar situation, on_lines doesn't appear to be locked to the buffer update (not curr_lines == prev_lines (cached buffer from last on_lines call)):
|
Here's a solid repro involving function _G.wreck_the_buffer(bufnr)
log_on_lines(bufnr)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, {'a', 'a', '', '', 'b', 'b'})
vim.lsp.util.apply_text_edits({
{
range = {
start = { line = 1, character = 1 },
["end"] = { line = 4, character = 0 },
}, newText = "\n\n"
}
})
end
function _G.log_on_lines(bufnr)
local old_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
vim.api.nvim_buf_attach(bufnr, false, {
on_lines = function(_, _, changedtick, firstline, old_lastline, new_lastline)
local new_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
local event = {
_1_bufnr = bufnr,
_2_changedtick = changedtick,
_3_firstline = firstline,
_4_old_lastline = old_lastline,
_5_new_lastline = new_lastline,
_6_old_lines = vim.list_slice(old_lines, firstline + 1, old_lastline),
_7_new_lines = vim.list_slice(new_lines, firstline + 1, new_lastline),
_8_firstline_incorrect = old_lines[firstline + 1] == new_lines[firstline + 1],
_9_lastline_incorrect = old_lines[old_lastline] == new_lines[new_lastline],
}
print(vim.inspect(event))
old_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
end;
})
end |
Here's another solid repro related to the undo history. To reproduce:
(To check the on_lines events the |
Found an even better repro: function _G.final_test(bufnr)
log_on_lines(bufnr)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, {'a', 'b', 'c', 'd', 'e', 'f'})
vim.api.nvim_buf_set_lines(bufnr, 2, 4, true, {'c', 'z', 'x', 'd'})
end |
Found another repro:
Strictly speaking, even selecting some code block with Visual mode and repeatedly shifting it with |
Neovim version (nvim -v)
0.6.0 commit 2ecf0a4
Vim (not Nvim) behaves the same?
N/A
Operating system/version
macOS 12.0
Terminal name/version
iterm 3.5
$TERM environment variable
xterm-256color
Installation
build from source
How to reproduce the issue
Install
texlab
LSP server from https://github.com/latex-lsp/texlab and download https://gist.github.com/clason/b9b64a8ceb67d00c245dc58743bb053cThen
nvim --clean -u minimal test.tex
, wait forReady!
to show upset ft=tex
(needed since vim defaults toplaintex
for empty.tex
files)eq<tab>foo<tab>
(note that a literal tab is inserted instead of jumping to the next placeholder)<esc>u
Expected behavior
no error (as before 2ecf0a4)
Actual behavior
The text was updated successfully, but these errors were encountered: