mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
3159a2c28f
Problem: With vim.treesitter.foldexpr, `o`-ing two lines above a folded region opens the fold. This does not happen with legacy foldexprs. For example, make a markdown file with the following text (without indentation), enable treesitter fold, and follow the instruction in the text. put cursor on this line and type zoo<Esc> initially folded, revealed by zo # then this fold will be opened initially folded, revealed by o<Esc> Analysis: * `o` updates folds first (done in `changed_lines`), evaluating foldexpr, and then invokes `on_bytes` (done in `extmark_splice`). * Treesitter fold allocates the foldinfo for added lines (`add_range`) on `on_bytes`. * Therefore, when treesitter foldexpr is invoked while running `o`, it sees outdated foldinfo. Solution: `extmark_splice`, and then `changed_lines`. This seems to be the standard order in other places, e.g., `nvim_buf_set_lines`. |
||
---|---|---|
.. | ||
api | ||
autocmd | ||
core | ||
editor | ||
ex_cmds | ||
fixtures | ||
legacy | ||
lua | ||
options | ||
plugin | ||
provider | ||
shada | ||
terminal | ||
treesitter | ||
ui | ||
vimscript | ||
example_spec.lua | ||
helpers.lua | ||
preload.lua |