Konfekt / FastFold

Speed up Vim by updating folds only when called-for.
708 stars 24 forks source link

fix: use win_execute() to avoid more side effects #74

Open tomtomjhj opened 1 year ago

tomtomjhj commented 1 year ago

Problem: The current implementation of s:WinDo() fails at avoiding some side effects. Specifically, :windo and :wincmd w trigger CursorMoved even if noautocmd is used (both in Vim and Nvim ≥ 0.10). This makes nvim's lsp hover window immediately close.

Solution: Use win_execute() if it's available.

update: in neovim, cursormoved is no longer fired for temporary movements https://github.com/neovim/neovim/pull/24675

tomtomjhj commented 1 year ago

Hmm this completely breaks everything. For example, with fdm=expr, :w should update the fold, but it doesn't. I guess win_execute also suppresses stuff related to updating folds.

tomtomjhj commented 1 year ago

Fixed. Turns out that some of the side effects in the old code were crucial for triggering the recomputation of the fold. So it should be triggered explicitly.

Konfekt commented 11 months ago

Hello, thanks for the additional fixes according to your recent force push. Somehow the diff is not very helpful anymore, could you quickly summarize what changed?

tomtomjhj commented 11 months ago

This PR reduces side effects in s:WinDo() (e.g., CursorMoved) by replacing :windo with win_execute(). The tricky part is that setting options in win_execute() doesn't trigger fold recomputation. IIRC the force pushes were various attempts to achieve this. The final solution is to call foldlevel(). Here is the version that is cleaner but breaks compatibility: https://github.com/tomtomjhj/FastFold/commit/cecb798b46ab22c0d974763f66e5741368822224

However, the problem in nvim that motivated this change has been fixed, so I'm no longer interested in this patch.