-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Vim exists 'Insert' mode if compatible mode is turned on and you switch into a different application and back.
How to reproduce:
0) ./configure --enable-gui=no --with-features=huge && make
- ./src/vim -U NONE -u NONE -i NONE -c ':set compatible'
- switch to 'Insert' mode by 'i'
- write some text and don't leave 'Insert' mode
- lose focus on Vim - f.e. by switching to a different window/application
- switch back to Vim and try to write again
Actual behavior:
The insert mode is gone and you need to type 'i' again.
Expected behavior:
The insert mode stays active until user presses Esc.
Environment:
- Vim version 8.2.2562 - compiled the current master branch from github
- OS: Fedora 32
- Terminal:GNOME Terminal
Additional context
The issue is reported by user for Fedora - the behavior started with adding the feature in 8.2. 2345 and can be worked around by unsetting t_fd and t_fe like :set t_fd= and :set t_fe=.
There is an incomplete analysis in the bug, where I was able to track down the reason why the bug appears. check_termcode() uses typebuf struct for comparing with termcodes list which will determine the key_name which is used later. typebuf has a different tb_off in compatible mode and in nocompatible, which seems to cause wrong interpretation of the incoming event - so Vim will interpret FOCUS_LOST as FOCUS_GAINED.
typebuf structure is used on many places and I wasn't able to track the issue further down...
Would you mind looking into it?
Thank you in advance!
Zdenek