R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
128 stars 15 forks source link

clear_line not working with R console in tmux #154

Open awoodx opened 1 week ago

awoodx commented 1 week ago

Having the R console in a separate tmux pane works better for my workflow, and I saw the recent tmux issue (https://github.com/R-nvim/R.nvim/issues/152). My R session works with tmux, but the clear_line option doesn't work. When I run a line in R, it appends to the text in the R console.

This is my R config: local opts = { clear_line = true, external_term = "tmux split-window -hf " }

jalvesaq commented 1 week ago

I can't replicate the issue. R.nvim reads my ~/.inputrc and correctly recognizes that my editing_mode should be "vi". When running R in a Tmux split pane, if there is any text in the R prompt, it is cleared when a command is sent.

jalvesaq commented 1 week ago

I also have this in my ~/.config/tmux/tmux.config:

set-window-option -g mode-keys vi

This in my ~/.bashrc:

set -o vi

And this in ~/.config/fish/config.fish:

fish_vi_key_bindings
awoodx commented 1 week ago

yes, I agree. The issue might not be related to tmux, but I do see instances where there clear_line isn't working, but I'm not able to reliably reproduce it. I will report back if I can a repro. Thanks!

awoodx commented 1 week ago

I think I found a way to reproduce it, it's related to the Escape key in emacs mode.

  1. use emacs keys: set editing-mode emacs in ~/.inputrc
  2. start Nvim, and launch R console in a separate tmux pane.
  3. Type some text (eg garbage) in the R console followed by the Escape key.
  4. Switch back to nvim, and select a line of text to R.

The garbage text isn't cleared.

jalvesaq commented 1 week ago

I can replicate the issue following your four steps. To be sure that I would be in "pure" emacs mode, I removed the vi mode from all configuration files (.inputrc, .bashrc, tmux.conf, and config.fish).

Of course, (n)vi(m) users inadvertently type the <Esc> key everywhere. However, I guess that we can't fix the issue in this case because Neovim has no way of knowing that the <Esc> key was typed on the R console.