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

^[[2;2R Printed when opening a file #17

Closed
W4RH4WK opened this issue Oct 6, 2016 · 8 comments
Closed

^[[2;2R Printed when opening a file #17

W4RH4WK opened this issue Oct 6, 2016 · 8 comments

Comments

@W4RH4WK
Copy link

W4RH4WK commented Oct 6, 2016

Hi there,

I use hexmode together with a bunch of other plugins and recently countered an error (after running +BundleUpdate) where a strange sequence of characters is printed to the buffer when opening a file. It looks like a terminal control sequence and I tracked this issue down to hexmode --- at least it does occur when hexmode is enabled and longer occurs when it's disabled.

Just before the file's content has been loaded:
1

After the content has been loaded:
2

After refreshing the terminal:
3

It follows the set of plugins I am currently running. Full vim config is available here but may be slightly out of date.

Plugin 'gmarik/vundle'

" vim plugins
Plugin 'L9'
Plugin 'MatchTag'
Plugin 'SirVer/ultisnips'
Plugin 'Solarized'
Plugin 'Tabular'
Plugin 'Valloric/YouCompleteMe'
Plugin 'closetag.vim'
Plugin 'fidian/hexmode'
Plugin 'fugitive.vim'
Plugin 'honza/vim-snippets'
Plugin 'kien/ctrlp.vim'
Plugin 'matchit.zip'
Plugin 'repeat.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'tComment'
Plugin 'taglist.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-surround'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

" filetype plugins
Plugin 'PProvost/vim-ps1'
Plugin 'Simple-JavaScript-Indenter'
Plugin 'eagletmt/neco-ghc'
Plugin 'fatih/vim-go'
Plugin 'genoma/vim-less'
Plugin 'kchmck/vim-coffee-script'
Plugin 'neovimhaskell/haskell-vim'
Plugin 'openscad.vim'
Plugin 'othree/html5.vim'
Plugin 'rust-lang/rust.vim'
Plugin 'vim-pandoc/vim-pandoc-syntax'

" debug plugins
Plugin 'listmaps.vim'
@fidian
Copy link
Owner

fidian commented Oct 6, 2016

It happens for me as well, but I don't know enough vimscript to attribute it to just this plugin. When I first noticed the problem I was hoping it only affected me. Uncommenting or disabling all of my other plugins except hexmode and the codes disappear. Using hexmode + colorscheme koehler and the codes appear again. It's pretty confusing to me. I suspect it has something to do with running file on line 61 but I can't figure out why that would produce those errors or any workaround to avoid the issue.

This is an ANSI escape code for a cursor position report, also known as CPR.

^[  Escape character
[   CSI
2;2 Number of lines, number of columns
R   Cursor position report

It is a response given from the terminal to a DECCIR, DECXCPR, or DSR (probably not what we use). My money is on DECSCPR. You can simulate this with bash: echo $'\e?6n' If you try that you won't see the ESC character on the terminal easily, but it's there. Ok, so it appears that the cursor is at line 2 column 2 consistently, but I don't yet know how this helps us out.

In my research I have found related bug reports and mailing list messages:

It also appears in different places. I can make a new file and it appears at the bottom, but for an existing file it appears at the top.

screenshot from 2016-10-06 08-34-16
screenshot from 2016-10-06 08-34-03

@W4RH4WK
Copy link
Author

W4RH4WK commented Oct 6, 2016

For me it does still appear if only hexmode is enabled. It came to my mind that there may be a problem with the color scheme, but it occurs even when I disable mine and use vim's default.

@fidian
Copy link
Owner

fidian commented Oct 6, 2016

Are you able to narrow down the conflict to see what other plugins cause hexmode to spit out these codes? I'll do the same on my end.

@fidian
Copy link
Owner

fidian commented Oct 6, 2016

Oh, I misread your last comment. Are you saying that you see this problem with an empty .vimrc and only loading hexmode? That's different than what I see.

@fidian
Copy link
Owner

fidian commented Oct 6, 2016

Well, found proof that ESC [ 6 n is being sent in a terminal capture. Not sure if this helps. See offset 0x143.

screenshot from 2016-10-06 12-48-19

@fidian
Copy link
Owner

fidian commented Oct 6, 2016

When I leave all of my plugins enabled and change my .vimrc and simply comment out colorscheme koehler, it works. Other codes appear, but they disappear automatically. Enabling colorscheme torte shows the codes again. I'm starting to wonder if this is some sort of timing issue and that running file when files open causes too much delay.

To test this further, I simply appended hexmode and my vimrc together. Next, I commented out the bit about pathogen. This eliminates the other plugins.

cat hexmode.vim ~/.vimrc > hexmode+vimrc
vim -C -u hexmode+vimrc empty-file

Anyway, summing up, simply adding the colorscheme koehler to the end of hexmode.vim and loading up hexmode with vim -C -u hexmode+vimrc empty-file causes the problem... More diagnosis necessary. :-(

fidian added a commit that referenced this issue Oct 6, 2016
This is to do the best that I can with #17, even though the issue
appears to be with vim itself.
@fidian
Copy link
Owner

fidian commented Oct 6, 2016

After a ton more debugging, it appears that with a very minimal .vimrc + pathogen + editorconfig (Note: Hexmode is not included), I get the same thing as long as I edit a file that's covered by the editorconfig plugin. It appears to be caused by running system() inside BufReadPre, BufReadPost and possibly BufNewFile. As such, this appears to be a vim-related bug and not specific to this plugin.

I did move the detection to BufReadPost and that seemed to help when calling file. Then I switched tactics and decided to run a search on the buffer for specific binary characters and that seems to help more.

I will happily accept better ideas for how to solve this problem in a more generic way!

I will be closing this issue. Is it fixed? Not really since I can duplicate the problem pretty easily. Save this as test-vimrc and run vim -c test-vimrc test-vimrc. You'll see escape codes for 1 second before the screen gets refreshed. I suppose a "fix" for this is to refresh the screen when it is done loading.

set nocompatible
au BufReadPre * call system('sleep 1')

Here's my obligatory screen shot of nothing loaded besides pathogen + editorconfig when editing a text file.

screenshot from 2016-10-06 16-56-52

@fidian fidian closed this as completed Oct 6, 2016
@W4RH4WK
Copy link
Author

W4RH4WK commented Oct 7, 2016

Thanks for your efforts.

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