Skip to content

Conversation

tomtomjhj
Copy link
Contributor

@tomtomjhj tomtomjhj commented Jun 8, 2023

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 neovim/neovim#24675

@tomtomjhj
Copy link
Contributor Author

tomtomjhj commented Jun 8, 2023

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
Copy link
Contributor Author

tomtomjhj commented Jun 8, 2023

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.

@tomtomjhj tomtomjhj force-pushed the win_execute branch 6 times, most recently from 7c7a37a to c7c7cbf Compare June 8, 2023 16:23
* 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). So use
  `win_execute()` if it's available.
* With `win_execute()`, setting fdm itself doesn't seem to trigger
  recomputation of fold. Querying the foldlevel seems to be sufficient
  for triggerring fold recomputation.
@Konfekt
Copy link
Owner

Konfekt commented Nov 30, 2023

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
Copy link
Contributor Author

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: tomtomjhj@cecb798

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants