Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing q does not quit presentation after leaving embedded terminal #188

Open
napmn opened this issue Dec 11, 2022 · 6 comments
Open

Pressing q does not quit presentation after leaving embedded terminal #188

napmn opened this issue Dec 11, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@napmn
Copy link

napmn commented Dec 11, 2022

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:

  1. Open presentation that is using terminal extension (e.g. from examples).
  2. Focus terminal, then press ctrl+a to get focus back to presentation.
  3. If presentation has multiple slides navigate using j / k -> works
  4. 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):
Screenshot 2022-12-11 at 9 42 51

Weird stuff copying into prompt when clicking anywhere in the terminal:
Screenshot 2022-12-11 at 9 43 16

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!

@napmn napmn added the bug Something isn't working label Dec 11, 2022
@napmn
Copy link
Author

napmn commented Dec 11, 2022

Some additional info:
Pressing q sometimes works when i follow these steps:

  1. starting terminal with bash: bash -il
  2. entering zsh
  3. press ctrl+a
  4. 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).

@napmn
Copy link
Author

napmn commented Dec 11, 2022

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.

@d0c-s4vage
Copy link
Owner

@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)

@d0c-s4vage
Copy link
Owner

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

@d0c-s4vage
Copy link
Owner

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)

@wrigleyster
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants