This happens for both vim and python3, I haven't tried with other
applications.

I'm not sure when readline and raw mode are activated, I would have to read
up on that.

Den sön 22 sep. 2024 02:39Martin D Kealey <mar...@kurahaupo.gen.nz> skrev:

> Does this happen with any raw-mode application, or just vim?
>
> When using readline in Emacs mode, the terminal is necessarily in raw mode.
>
> I suspect what you're seeing is that 'fg' bound to a key is bypasses the
> normal "exit readline" that would restore the settings. Then when vim exits
> or is suspended, Bash notices that it's still in raw mode (-icanon), but
> doesn't otherwise know the details of exactly how you want it cooked
> (+icanon but what else?).
>
> I'll check on this when I get back to my PC.
>
> -Martin
>
> On Sat, 21 Sep 2024, 09:23 David Moberg, <kaddk...@gmail.com> wrote:
>
>> Configuration Information [Automatically generated, do not change]:
>> Machine: x86_64
>> OS: linux-gnu
>> Compiler: gcc
>> Compilation CFLAGS: -g -O2 -fno-omit-frame-pointer
>> -mno-omit-leaf-frame-pointer -flto=auto -ffat-lto-objects
>> -fstack-protector-strong -fstack-clash-protection -Wformat
>> -Werror=format-security -fcf-protection -Wall
>> uname output: Linux Tugge 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC
>> Fri Aug 30 12:02:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
>> Machine Type: x86_64-pc-linux-gnu
>>
>> Bash Version: 5.2
>> Patch Level: 21
>> Release Status: release
>>
>> Description:
>>         When a process/job is suspended, foregrounded via ctrl-a as a
>> keybinding for fg, and then
>>         suspended again, the tty will be in a surprising state where no
>> input is seen (-echo)
>>
>> Repeat-By:
>> |       bind -x '"\C-a":"fg"'   # bind C-A to perform fg
>>         vim                     #
>>         <ctrl-z>                # Terminal still works
>>         stty -a > working.txt   # store tty settings
>>         <ctrl-a>                # Put vim in foreground again
>>         :q                      # Quit vim
>>         vim                     # Start a new vim session (*)
>>         <ctrl-z>                # Terminal is broken
>>         stty -a > broken.txt    # store tty settings
>>         #type text and no echo
>>
>>         Dumping the tty configuration before and after the broken state
>> reveals this diff after the
>>         second vim command above (*) has been executed:
>>
>>         ```console
>>         $ diff working.txt broken.txt
>>         4c4
>>         < werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
>>         ---
>>         > werase = ^W; lnext = <undef>; discard = <undef>; min = 1; time =
>> 0;
>>         6c6
>>         < -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
>> icrnl
>> ixon -ixoff
>>         ---
>>         > -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
>> -icrnl ixon -ixoff
>>         9c9
>>         < isig icanon iexten echo echoe echok -echonl -noflsh -xcase
>> -tostop -echoprt
>>         ---
>>         > isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase
>> -tostop -echoprt
>>         ```
>>
>>         The tty can get back into working state by running `stty sane`.
>>
>>         By redoing the <start vim> <ctrl-z> <ctrl-a> <quit vim> <stty
>> sane>
>> it can be seen that the
>>         terminal will only be broken after every second invocation.
>>
>>         Similar issue(?) in fish that has been resolved:
>>                 https://github.com/fish-shell/fish-shell/issues/2114
>>
>>         I have experienced the same weirdness with other applications than
>> vim, for example python3.
>>         I have experienced the issue several terminals: Wezterm, xfce-4
>> terminal.
>>
>

Reply via email to