The current implementation of the hook to extract highlight info from extmarks is really slow. Slow to the point where, in neovide, there's a 1-2s lag between me starting to scroll with my mouse and anything happening if current_scope is enabled. The changes in this PR make the scrolling happen immediately, and I also no longer get any lags when moving my cursor by holding a down or up key, which is happening (especially with files larger than ~200ish lines) on master.
For the most part, this should be equivalent to the old code; in theory, there could be cases where the nested iteration yields a different answer, but I believe that it would require two of the highlights we are looking for to be applied at the same buffer position, and I don't think that that is really an edge case worth preserving (but am happy to modify these changes if you'd prefer that we retain the exact same behavior there).
At first I thought it was just the excessive looping in the second part of the function that made it slow, but changing that has given me just moderate improvements; switching from vim.inspect_pos to nvim_buf_get_extmarks gave me a much higher speedup.
The current implementation of the hook to extract highlight info from extmarks is really slow. Slow to the point where, in neovide, there's a 1-2s lag between me starting to scroll with my mouse and anything happening if
current_scope
is enabled. The changes in this PR make the scrolling happen immediately, and I also no longer get any lags when moving my cursor by holding a down or up key, which is happening (especially with files larger than ~200ish lines) on master.For the most part, this should be equivalent to the old code; in theory, there could be cases where the nested iteration yields a different answer, but I believe that it would require two of the highlights we are looking for to be applied at the same buffer position, and I don't think that that is really an edge case worth preserving (but am happy to modify these changes if you'd prefer that we retain the exact same behavior there).
At first I thought it was just the excessive looping in the second part of the function that made it slow, but changing that has given me just moderate improvements; switching from
vim.inspect_pos
tonvim_buf_get_extmarks
gave me a much higher speedup.