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

Running bubbletea apps inside vim gives bad output #797

Open
caarlos0 opened this issue Aug 11, 2023 · 1 comment
Open

Running bubbletea apps inside vim gives bad output #797

caarlos0 opened this issue Aug 11, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@caarlos0
Copy link
Member

caarlos0 commented Aug 11, 2023

Being experimenting with running bubbletea programs inside vim/neovim using :!app, here's what I've found:

Problem 1: stdin and opening a tty

If you don't pass a WithInput option, bubbletea will fallback to /dev/stdin, which is OK, but then it'll try to open a new tty, which fails inside vim.

Passing WithInput(nil) fixes the issue.

Problem 1.2: WithInput(os.Stdin)

If instead of a nil input, you pass os.Stdin directly, you get a even weirder error:

:!go run .
^[[?25lcould not run program: error creating cancelreader: add reader to epoll interest list
exit status 1

shell returned 1

Problem 2: ansi escape codes in output

Ok, let's keep the WithInput(nil), if you then run the program from within vim, you'll get ansi escape code sequences all over the place:

:!go run .
^[[?25l
 / Spinning...

h/l, ←/→: change spinner • q: exit
                                  ^[[0D^[[1A^[[1A^[[1A^[[2K^[[1A^[[0D^[[2K
 - Spinning...
^[[1B^[[1B^[[0D^[[1A^[[1A^[[1A^[[2K^[[1A^[[0D^[[2K
 \ Spinning...
^[[1B^[[1B^[[0D^[[1A^[[1A^[[1A^[[2K^[[1A^[[0D^[[2K
 | Spinning...
^[[1B^[[1B^[[0D^[[1A^[[1A^[[1A^[[2K^[[1A^[[0D^[[2K
 / Spinning...
^[[1B^[[1B^[[0D^[[1A^[[1A^[[1A^[[2K^[[1A^[[0D^[[2K

To be honest, that seems to happen with other things too, e.g., fish shell:

:!echo (set_color --bold magenta) "Hello world"
^[[1m^[[35m Hello world

Press ENTER or type command to continue

Footnotes

  • Lipgloss examples seem to work properly
  • Termenv examples also print the escape codes, so maybe the problem is there?
  • I think the biggest real bugs here involve setting the input, not sure what the right behavior should be though
@caarlos0
Copy link
Member Author

some screenshots, fwiw:

gum

image

mods

image

lipgloss example

image

bubbletea example

image

bubbletea example (modified, nil input)

image

termenv example
CleanShot 2023-08-11 at 15 36 48@2x

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

1 participant