lookatme
lookatme copied to clipboard
Pressing `q` does not quit presentation after leaving embedded terminal
Describe the bug
Can't use q
to quit presentation after using terminal from terminal
extension. Using q
to quit works when terminal is not used.
To Reproduce Steps to reproduce the behavior:
- Open presentation that is using terminal extension (e.g. from
examples
). - Focus terminal, then press
ctrl+a
to get focus back to presentation. - If presentation has multiple slides navigate using
j / k
-> works - Press
q
to quit presentation -> presentation does not quit but freezes
Expected behavior
Pressing q
after exiting terminal will quit presentation.
Screenshots
Original terminal after killing process from other terminal (i pressed multiple q
and Q
when trying to exit presentation):
Weird stuff copying into prompt when clicking anywhere in the terminal:
Environment (please complete the following information):
- OS: Mac OS
- Lookatme Version 2.5.4
- tested on kitty, alacritty, macos terminal and with bash / zsh - all same behavior
Additional context
Log output:
DEBUG:lookatme.RENDER:Rendering slide 0
DEBUG:lookatme.RENDER: Rendering token {'type': 'heading', 'level': 1, 'text': 'A Plain Terminal'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'paragraph', 'text': 'A plain bash terminal:'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'code', 'lang': 'md', 'text': 'terminal8\nbash -il\n
'}
DEBUG:lookatme:Took 1.4066696166992188e-05s to render 25 bytes
DEBUG:lookatme.RENDER: Rendering token {'type': 'code', 'lang': 'terminal8', 'text': 'bash -il'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'heading', 'level': 1, 'text': 'A Plain Terminal'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'paragraph', 'text': 'A plain bash terminal:'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'code', 'lang': 'md', 'text': 'terminal8\nbash -il\n
'}
DEBUG:lookatme:Took 8.106231689453125e-06s to render 25 bytes
DEBUG:lookatme.RENDER: Rendering token {'type': 'code', 'lang': 'terminal8', 'text': 'bash -il'}
DEBUG:lookatme.RENDER:Rendered slide 0 in 0.14720892906188965
DEBUG:lookatme.RENDER:Rendering slide 1
DEBUG:lookatme.RENDER: Rendering token {'type': 'heading', 'level': 1, 'text': 'Next slide'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'paragraph', 'text': 'This is next slide'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'heading', 'level': 1, 'text': 'Next slide'}
DEBUG:lookatme.RENDER: Rendering token {'type': 'paragraph', 'text': 'This is next slide'}
DEBUG:lookatme.RENDER:Rendered slide 1 in 0.0011858940124511719
DEBUG:lookatme:KEY: e
DEBUG:lookatme:KEY: c
DEBUG:lookatme:KEY: h
DEBUG:lookatme:KEY: o
DEBUG:lookatme:KEY:
DEBUG:lookatme:KEY: t
DEBUG:lookatme:KEY: e
DEBUG:lookatme:KEY: s
DEBUG:lookatme:KEY: t
DEBUG:lookatme:KEY: enter
DEBUG:lookatme:KEY: ctrl a
DEBUG:lookatme:KEY: j
DEBUG:lookatme:KEY: k
DEBUG:lookatme:KEY: q
DEBUG:lookatme:KEY: backspace
DEBUG:lookatme:KEY: ctrl a
DEBUG:lookatme:KEY: j
DEBUG:lookatme:KEY: q
DEBUG:lookatme:Terminating terminal 1/2
DEBUG:lookatme:Terminating terminal 2/2
Let me know if you need some additional info. Thanks!
Some additional info:
Pressing q
sometimes works when i follow these steps:
- starting terminal with bash:
bash -il
- entering
zsh
- press
ctrl+a
- press
q
I wrote that it works sometimes because I often get error mention in #139 when entering zsh
. I also get this error from time to time if I put zsh
as a starting command for the terminal. What I noticed is that this error occurs if the zsh shell is loaded instantly (sometimes it takes ~1sec and in that case the error does not occur).
I just found a solution specific for my setup. My default shell is zsh
. When I use bash -il
as default terminal command I'm not able to use q
to quit. When I use zsh
as default terminal command it often crashes as mentioned in the comment above.
When I use zsh -fdi
(removing all configuration) as default terminal command I am able to navigate and quit after using embedded terminal! 🎉
I'm using oh-my-zsh
so that may have some effect I guess.
I'm not sure @d0c-s4vage if this is worth investigating further. If not, feel free to close the issue.
@napmn there's some oddness in how the embedded terminal captures keypresses, and especially with knowing if the terminal has focus, and how to make it let go of that focus.
I thought I had an issue open to make this easier to work with, but I'm not finding it. I'll make a new one to specifically address that with:
- Some visible indicator that the terminal has the focus
- A visible reminder of how to escape the terminal (and make it let go of focus)
As for the error that you experience sometimes, I haven't been able to reproduce it yet. I'll spend some time trying to figure that one out.
For now though, #191 should handle the visual updates to the terminal. #161 is the issue I was thinking of to make sure keybindings to escape the terminal are set/working correctly
Hmm, zsh -fdi
doesn't have the same problem... for reference:
-
-f
- same as--no-rcs
-
-d
- same as--no-globalrcs
-
-i
- same as--interactive
(interesting SO context here)
typing exit
or pressing Ctrl+D, while on an empty line in the terminal, will kill bash, and will subsequently ensure that pressing q
exits the presentation without hanging.