mouseterm-plus icon indicating copy to clipboard operation
mouseterm-plus copied to clipboard

Bug when I open a file using vim

Open liudangyi opened this issue 10 years ago • 12 comments

screen shot 2015-02-25 at 4 10 22 pm screen shot 2015-02-25 at 4 17 35 pm

I use spf13-vim. It shows strange codes after I open a file.

liudangyi avatar Feb 25 '15 08:02 liudangyi

Thanks for your reporting.

Progress report:

I installed spf13-vim. I found that this problem can be reproduced on other terminals.

XTerm patch level 314 screenshot1

Tera Term 4.85 screenshot2

I'm debugging it with trachet. screenshot3.png

Naked vim can handle answers for tcap-query sequences. I suspect any of vim plugins (which may use some maps or getchar() function) prevents it.

saitoha avatar Feb 25 '15 12:02 saitoha

@liudangyi Can you make the minimal reproducible VimScript example for this problem? Or can you tell me which plugin causes this problem?

saitoha avatar Feb 26 '15 17:02 saitoha

Following vimrc script will reproduce the problem.

set rtp+=~/.vim/bundle/vundle
call vundle#rc()

Bundle 'gmarik/vundle'
Bundle 'bling/vim-airline'
Bundle 'majutsushi/tagbar'

set laststatus=2
syntax on

liudangyi avatar Feb 27 '15 05:02 liudangyi

@liudangyi Thanks!

saitoha avatar Mar 01 '15 13:03 saitoha

@liudangyi Now I understand what causes this problem.

This is not terminal's issue. When vim accept responses for tcap-query, the terminal should be set to "raw mode" to prevent echo-back. But some vim plugins do shell dispatching at same timing. It set the terminal to "cooked mode" for a moment.

I think this is vim's issue. The following patch will solve your problem. But it might produce unintended side effects.

diff -r 3af822eb4da5 src/os_unix.c
--- a/src/os_unix.c Sat Feb 28 13:11:45 2015 +0100
+++ b/src/os_unix.c Sun Mar 01 23:11:24 2015 +0900
@@ -4179,8 +4179,10 @@
    goto error;

     out_flush();
+#if 0
     if (options & SHELL_COOKED)
    settmode(TMODE_COOK);       /* set to normal mode */
+#endif

     /*
      * Do this loop twice:

saitoha avatar Mar 01 '15 14:03 saitoha

@liudangyi This patch for the tagbar plugin may be better solution. Can you tell me whether it works?

diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index 49b2eff..e4b26cf 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -3644,7 +3644,7 @@ function! s:ExecuteCtags(ctags_cmd) abort
         call s:debug(v:statusmsg)
         redraw!
     else
-        let ctags_output = system(a:ctags_cmd)
+        silent let ctags_output = system(a:ctags_cmd)
     endif

     if &shell =~ 'cmd\.exe'

saitoha avatar Mar 14 '15 14:03 saitoha

Sorry, but it doesn't work.

liudangyi avatar Mar 14 '15 15:03 liudangyi

Nothing is changed?

saitoha avatar Mar 14 '15 16:03 saitoha

Above patch solves this "echo-back" problem at least in my environment (with default settings of spf-13, vim 7.4.648 in OSX/vim 7.4.589 in Debian sid).

saitoha avatar Mar 14 '15 16:03 saitoha

Yes, nothing changed. screen shot 2015-03-15 at 1 53 11 pm screen shot 2015-03-15 at 1 53 15 pm

liudangyi avatar Mar 15 '15 05:03 liudangyi

OK, please try the following patch for vim. (Former patch for src/os_unix.c is buggy. It had bad side effects against :shell and :! command.)

https://gist.github.com/saitoha/9819c355445e269f87ff

saitoha avatar Mar 15 '15 11:03 saitoha

I sent the patch for this issue to vim_dev.

https://groups.google.com/d/msg/vim_dev/8ciQGDB-0Og/NiaJYwQHKF8J

I'm glad if you test it.

saitoha avatar Apr 29 '15 03:04 saitoha