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

on_stderr function doesn't excute #374

Open
williamhCode opened this issue Dec 20, 2022 · 6 comments
Open

on_stderr function doesn't excute #374

williamhCode opened this issue Dec 20, 2022 · 6 comments

Comments

@williamhCode
Copy link

williamhCode commented Dec 20, 2022

I have a simple on_stderr function in my setup function.

    on_stderr = function(t, job, data, name)
        print("aaaaaaaaaaaaaaaaaaaaaa")
        require("toggleterm").toggle_all()
    end,

This prints and toggles the terminal if my terminal outputs to stderr. However, it doesn't seem to be working. I've tried using on_stdout and it works perfectly fine.

nvim version: v0.8.1

@akinsho
Copy link
Owner

akinsho commented Dec 20, 2022

@williamhCode can you confirm that the command you are running definitely outputs to stderr as some programs don't always behave as expected in this regard

@williamhCode
Copy link
Author

williamhCode commented Dec 21, 2022

Here is a video of me manually echoing to stderr. Also i just realized the stdout behavior is a bit weird. As soon as I type something in the terminal, it executes. Shouldn't it execute only when I run a command that outputs to stdout?

on_stderr:
https://user-images.githubusercontent.com/83525937/209018080-47542017-dbc3-418f-b7b8-7095bd979ef9.mov

on_stdout:
https://user-images.githubusercontent.com/83525937/209018864-48b1e52e-3b59-43d2-890a-57872fa717bc.mov

Note: I tried it without tmux and still had the same behavior.

@akinsho
Copy link
Owner

akinsho commented Dec 21, 2022

@williamhCode just to clarify, this plugin essentially wraps neovim's native terminal which has some somewhat complex handling for things like this. I'd recommend trying to use :h termopen() yourself and seeing if it behaves the same way, in which case this is likely something to be reported upstream.

@williamhCode
Copy link
Author

ok thx, i'll try it out!

@williamhCode
Copy link
Author

I just confirmed it's neovim problem. But it seems like that's how it's intended to work with no plans to fix it (it's been around since 2015!!), which is quite troublesome.

The reasoning and a workaround is explained here:
neovim/neovim#2836 (comment)

@akinsho
Copy link
Owner

akinsho commented Dec 22, 2022

Thanks for digging in @williamhCode I thought it might be something like that but glad to see that actually issue. I think in this case what I'll do is remove/refactor on stdout/stderr to be more generic like on_output and link to this issue, eventually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants