saitoha / mouseterm-plus

An experimental fork of brodie's MouseTerm.
GNU General Public License v2.0
71 stars 4 forks source link

Bug when I open a file using vim #3

Open liudangyi opened 9 years ago

liudangyi commented 9 years ago

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.

saitoha commented 9 years ago

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 commented 9 years ago

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

liudangyi commented 9 years ago

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
saitoha commented 9 years ago

@liudangyi Thanks!

saitoha commented 9 years ago

@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 commented 9 years ago

@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'
liudangyi commented 9 years ago

Sorry, but it doesn't work.

saitoha commented 9 years ago

Nothing is changed?

saitoha commented 9 years ago

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).

liudangyi commented 9 years ago

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

saitoha commented 9 years ago

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 commented 9 years ago

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.