FS#78585 - [ncurses][vim] vim enters -- more -- view when losing focus with testing/ncurses

Attached to Project: Arch Linux
Opened by Mike Yuan (YHNdnzj) - Wednesday, 24 May 2023, 10:11 GMT
Last edited by Toolybird (Toolybird) - Saturday, 05 August 2023, 21:45 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To David Runge (dvzrv)
Levente Polyak (anthraxx)
Morten Linderud (Foxboron)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

After upgrading ncurses to 6.4_20230520-1, vim automatically enters -- more -- view when the terminal window loses focus. Downgrading to 6.4-1 resolves the issue for me.

Additional info:
* package version(s)
ncurses 6.4_20230520-1
vim 9.0.1572-1

Steps to reproduce:

1. Open vim
2. Switch to another window
This task depends upon

Closed by  Toolybird (Toolybird)
Saturday, 05 August 2023, 21:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  "Resolved"

R.I.P. Bram. Legend
Comment by David Runge (dvzrv) - Wednesday, 24 May 2023, 11:52 GMT Comment by David Runge (dvzrv) - Friday, 26 May 2023, 11:45 GMT
@anthraxx, @Foxboron: Can we try updating vim to see whether a later version fixes this behavior?
Comment by T.J. Townsend (blakkheim) - Thursday, 01 June 2023, 18:58 GMT
Is there an upstream bug report about this anywhere?

edit: I can't seem to reproduce the problem with ncurses from testing
Comment by John Nguyen (ailesh1y) - Sunday, 04 June 2023, 15:00 GMT
I believe this is a bug with Vim and has to do with focus event tracking. There are multiple bug reports about it upstream, but no clear indication what work is being done:

<https://github.com/vim/vim/issues/12338#issuecomment-1535583086>

One way to fix it, taken from <https://vimhelp.org/term.txt.html#xterm-focus-event>:

```
let &t_fe = "\<Esc>[?1004h"
let &t_fd = "\<Esc>[?1004l"
execute "set <FocusGained>=\<Esc>[I"
execute "set <FocusLost>=\<Esc>[O"
```

Or if using vim9script:

```
execute '&t_fe = "\<Esc>[?1004h"'
execute '&t_fd = "\<Esc>[?1004l"'
execute "set <FocusGained>=\<Esc>[I"
execute "set <FocusLost>=\<Esc>[O"
```

It appears to be working correctly for tmux-* and xterm-*, but not for terminals like alacritty and foot... I've added the following to my .vimrc (vim9script):

```
if &term == 'alacritty' || &term == 'foot'
execute '&t_fe = "\<Esc>[?1004h"'
execute '&t_fd = "\<Esc>[?1004l"'
execute "set <FocusGained>=\<Esc>[I"
execute "set <FocusLost>=\<Esc>[O"
endif
```
Comment by Dimitri Kaparis (dkaparis) - Thursday, 22 June 2023, 09:42 GMT
This issue may be related: https://codeberg.org/dnkl/foot/issues/1367.

It has link to a patch to ncurses to solve it for foot: https://lists.gnu.org/archive/html/bug-ncurses/2023-06/msg00001.html.

On my system, I have an issue with ranger running in foot, when switching focus. The suggested workaround to use the
`foot-terminfo` package solves it for me.
Comment by Mike Yuan (YHNdnzj) - Saturday, 05 August 2023, 12:28 GMT
Belated status update, but I can no longer reproduce this with latest vim and ncurses.

Loading...