10000 fix(terminal): avoid more `busy_start` lacking `busy_stop` by seandewar · Pull Request #32509 · neovim/neovim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
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

fix(terminal): avoid more busy_start lacking busy_stop #32509

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

seandewar
Copy link
Member

Problem: after #32458, it may still be possible for busy_start UI events to be emitted without matching busy_stops in the terminal.

Solution: do terminal_enter's cursor visibility check immediately after setting/restoring State so it occurs before events. This ensures that if pending escape sequences are processed while in terminal_enter, the cursor's initial visibility is set before is_focused is checked by term_settermprop.

As a result, we can move the call to showmode back to where it was originally.

Problem: after neovim#32458, it may still be possible for `busy_start` UI events to be
emitted without matching `busy_stop`s in the terminal.

Solution: do `terminal_enter`'s cursor visibility check immediately after
setting/restoring State so it occurs before events. This ensures that if pending
escape sequences are processed while in `terminal_enter`, the cursor's initial
visibility is set before `is_focused` is checked by `term_settermprop`.

As a result, we can move the call to `showmode` back to where it was originally.
@github-actions github-actions bot added the terminal built-in :terminal or :shell label Feb 18, 2025
@seandewar seandewar marked this pull request as ready for review February 18, 2025 16:07
@seandewar seandewar merged commit f3ce675 into neovim:master Feb 19, 2025
38 checks passed
@seandewar seandewar deleted the i-hate-cursors branch February 19, 2025 10:47
@phanen
Copy link
Contributor
phanen commented Feb 21, 2025

This problem still exist for me... I can stably reproduce with:
nvim --clean -u minimal.lua +term bash, then press a<c-x><c-e>.

VIMRUNTIME=./runtime VISUAL='./build/bin/nvim --clean -u minimal.lua' ./build/bin/nvim --clean -u minimal.lua +'term bash' (then a<c-x><c-e>).

minimal.lua:

-- Run this file as `nvim --clean -u minimal.lua`
for name, url in pairs {
  ['flatten.nvim'] = 'https://github.com/willothy/flatten.nvim',
  ['gitsigns.nvim'] = 'https://github.com/lewis6991/gitsigns.nvim',
  ['nvim-treesitter-context'] = 'https://github.com/nvim-treesitter/nvim-treesitter-context',
} do
  local install_path = vim.fn.fnamemodify('nvim_issue/' .. name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

vim.cmd([[au BufReadPost * sil! norm! g`"zv']])
vim.o.clipboard = 'unnamedplus'

require('flatten').setup {}
require('treesitter-context').setup {}
require('gitsigns').setup {}

Bisected, not happened before https://github.com/neovim/neovim/commit/0dd933265ff2e64786fd30f949e767e10f401519...

@seandewar
Copy link
Member Author
seandewar commented Feb 21, 2025

@phanen Hmm, that doesn't reproduce for me. Maybe the inner Nvim (that's momentarily spawned by <C-X><C-E> before flatten does its magic) is still using your personal config there, as I had to
modify minimal.lua to set $VISUAL to build/bin/nvim --clean -u minimal.lua so flatten works for me (otherwise the inner Nvim used my personal config which doesn't have flatten; both the inner and outer Nvim need it to work). 🤔

@phanen
Copy link
Contributor
phanen commented Feb 22, 2025

@seandewar Sorry for missing that. I just updated my reproduce. (also rm -rf ~/.config/nvim), hope this can reproduce..

@seandewar
Copy link
Member Author
seandewar commented Feb 22, 2025

Thanks! That repro'd it for me; this seems to be a unique case.

From a quick GDBing, it seems nvim_set_current_buf is called from an event while in terminal_execute, where the destination buffer has no terminal. That causes terminal_execute to return early here.

Although s->term remains unchanged here, multiple events including escape codes to change cursor visibility can be processed within the same terminal_execute call, causing term_settermprop to not call ui_busy_start/stop here if cursor visibility changes after the buffer switch, but before the epilogue of terminal_enter (as is_focused now returns false).

I don't have any time left today; I'll try to address that later. 👍

@MariaSolOs
Copy link
Member

I'm also still having cursor issues :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
terminal built-in :terminal or :shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0