Terminal + Neovim: FocusLost/Gained events don't fire. #15770

Closed
opened 2026-01-31 04:47:53 +00:00 by claunia · 4 comments
Owner

Originally created by @mikatpt on GitHub (Nov 4, 2021).

Originally assigned to: @zadjii-msft on GitHub.

Windows Terminal version (or Windows build number)

1.12.2931.0

Other Software

Neovim 0.5+

Steps to reproduce

Steps to reproduce:

  1. Run Neovim 0.5 or higher using the following min.vim file, with the command nvim -u min.vim --clean
" min.vim
autocmd FocusLost * echo "Focus Lost"
autocmd FocusGained * echo "Focus Gained"
  1. Click away from terminal. Click to.
  2. Vim command line output at the bottom of the screen should update with the echoed text.

Expected Behavior

See title and steps to reproduce. This works in all Linux/MacOS terminals I've used, including Alacritty, Kitty, and iTerm2, as well as in tmux sessions if focus-events are enabled.

The Vim/Neovim release is not particularly important unless you would also like to test in tmux; in that case, choose a release any time after April 2021 and put set -g focus-events on in your .tmux.conf

Actual Behavior

Nothing happens.

Originally created by @mikatpt on GitHub (Nov 4, 2021). Originally assigned to: @zadjii-msft on GitHub. ### Windows Terminal version (or Windows build number) 1.12.2931.0 ### Other Software Neovim 0.5+ ### Steps to reproduce Steps to reproduce: 1) Run Neovim 0.5 or higher using the following `min.vim` file, with the command `nvim -u min.vim --clean` ```vimL " min.vim autocmd FocusLost * echo "Focus Lost" autocmd FocusGained * echo "Focus Gained" ``` 2) Click away from terminal. Click to. 3) Vim command line output at the bottom of the screen should update with the echoed text. ### Expected Behavior See title and steps to reproduce. This works in all Linux/MacOS terminals I've used, including Alacritty, Kitty, and iTerm2, as well as in tmux sessions if focus-events are enabled. The Vim/Neovim release is not particularly important unless you would also like to test in tmux; in that case, choose a release any time after April 2021 and put `set -g focus-events on` in your `.tmux.conf` ### Actual Behavior Nothing happens.
Author
Owner

@j4james commented on GitHub (Nov 4, 2021):

I suspect this is because we don't support XTerm's focus event mode (private mode 1004). I thought there might have been an issue for it already, but I haven't been able find one.

Edit: Not a duplicate as such, but I see now it has been discussed before here: https://github.com/microsoft/terminal/issues/10531#issuecomment-872398721

@j4james commented on GitHub (Nov 4, 2021): I suspect this is because we don't support XTerm's focus event mode (private mode 1004). I thought there might have been an issue for it already, but I haven't been able find one. Edit: Not a duplicate as such, but I see now it has been discussed before here: https://github.com/microsoft/terminal/issues/10531#issuecomment-872398721
Author
Owner

@zadjii-msft commented on GitHub (Nov 4, 2021):

Well cool, I would have suspected there was an issue already for this. Plumbing through conpty shouldn't be too hard, if a bit annoying.

@zadjii-msft commented on GitHub (Nov 4, 2021): Well cool, I would have suspected there was an issue already for this. Plumbing through conpty shouldn't be too hard, if a bit annoying.
Author
Owner

@zadjii-msft commented on GitHub (Apr 7, 2022):

Oh boy I sure did go overboard on my branch off #12799. We may just have to do this whole thing, so, here it is:

gh-11682-works

(left is before, right is after)

note to self: ~/nvim.appimage -u ~/gh-11682.vim ~/gh-11682.vim to do the thing

dev/migrie/b/2988-focus-fg-with-owner...dev/migrie/f/11682-vt-focus-events

@zadjii-msft commented on GitHub (Apr 7, 2022): Oh boy I sure did go overboard on my branch off #12799. We may just have to do this whole thing, so, here it is: ![gh-11682-works](https://user-images.githubusercontent.com/18356694/162237799-3f982ffb-db09-4294-bb45-a1b6bcb4f1c8.gif) (left is before, right is after) note to self: `~/nvim.appimage -u ~/gh-11682.vim ~/gh-11682.vim` to do the thing [`dev/migrie/b/2988-focus-fg-with-owner`...`dev/migrie/f/11682-vt-focus-events`](https://github.com/microsoft/terminal/compare/dev/migrie/b/2988-focus-fg-with-owner...dev/migrie/f/11682-vt-focus-events)
Author
Owner

@ghost commented on GitHub (May 24, 2022):

:tada:This issue was addressed in #12900, which has now been successfully released as Windows Terminal Preview v1.14.143.🎉

Handy links:

@ghost commented on GitHub (May 24, 2022): :tada:This issue was addressed in #12900, which has now been successfully released as `Windows Terminal Preview v1.14.143`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.14.143) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15770