simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.16k stars 158 forks source link

cannot input words into terminal #218

Closed Civitasv closed 2 years ago

Civitasv commented 2 years ago

So, I have codes to print any character I input to the terminal. Like:

fn main() {
    for b in io::stdin().bytes() {
        let c = b.unwrap() as char;
        println!("{}", c);
    }
}

Actual behavior: But when I run it, the execute terminal won't let me input and it will be closed after whatever key I click. image

Expected behavior: I should be able to input, and when I input <C-c>, it will stop.

Any idea?

simrat39 commented 2 years ago

You can press i to go into insert mode in the terminal buffer, and input whatever you want

Civitasv commented 2 years ago

When I press i, yes, it enter into insert mode, but then after I input something, it'll disappear. See: Peek 2022-07-14 10-29

simrat39 commented 2 years ago

Looks like the process exits (successfully as well). For some reason, it isn't waiting for your input.

Could you test this code out?

fn main() {
    loop {
        let mut a = String::new();
        io::stdin().read_line(&mut a);
        println!("{}", a)
    }
}
Civitasv commented 2 years ago

I find it weird. I think it enters into loop and wait for my input in the terminal. But I can't input anything in it(and you can see I've entered into terminal mode from normal mode). After click Ctrl+C, it exits.

Peek 2022-07-14 13-15

You can see my config for rust-tools.

simrat39 commented 2 years ago

Don't think this is an issue with rust-tools, but with your terminal. What happens if you run the code outside of neovim? Does the issue still persist?

Civitasv commented 2 years ago

I've tested in vscode, it works fine.