vim-rails icon indicating copy to clipboard operation
vim-rails copied to clipboard

strange text at the top of vim when starting it

Open bsylvain opened this issue 3 years ago • 13 comments

This problem occurs when I uncomment vim-rails in .vimrc and that I restart Vim without opening a file. I just installed vim.rails with bundler.vim and dispatch.vim

this weird text :`$r2 q^[^[[?12;4$y appear next to the '1' of the first line.

It seems the string is not really there. As soon as the space it occupy is interacted with, it just vanish and the space previously occupied by the char(s) behave normaly.

Vim 8.2.2995, vim-rails installed with vim-plug.

bsylvain avatar Jun 17 '21 16:06 bsylvain

I don't know what this could be. You could try commenting out portions of rails#buffer_setup() and see if you can narrow down the cause.

tpope avatar Jun 17 '21 21:06 tpope

I don't know what this could be. You could try commenting out portions of rails#buffer_setup() and see if you can narrow down the cause.

Hi Tim, first off thanks for all your amazing contributions to the VIM community!

I'm setting this weird text glob on launch too, screenshot below.

Tried as suggested and the issue disappears if I comment the call to s:BufProjectionCommands and this code block. Bringing back either of those two has the issue re-appearing.

Hope that helps?!


clowder avatar Sep 30 '21 13:09 clowder

It's a start, but narrower would be more actionable. You may need to dive into the s:BufProjectionCommands() definition or even deeper.

tpope avatar Sep 30 '21 15:09 tpope

It's a start, but narrower would be more actionable. You may need to dive into the s:BufProjectionCommands() definition or even deeper.

Interestingly, in s:BufProjectionCommands() it seems to be the for loop causing that specific part of the issue:

https://github.com/tpope/vim-rails/blob/03a5c3e85411db1488cdfd1029d2a91f9327c8a2/autoload/rails.vim#L2804-L2806

Replacing rails#app().commands() with an empty map items({}) seems to maintain the "fix", provided the code block linked to previously is also still commented out. Weirdly commenting out the internals of the for method doesn't help, so it seems to be something to do with the internals of rails#app().commands()?!

Hope that helps?

clowder avatar Oct 01 '21 10:10 clowder

That maps to s:app_commands(), which in turn calls s:app_projections(). Nothing jumps out as suspicious in either of those so I guess you have more bisecting to do.

tpope avatar Oct 01 '21 14:10 tpope

This seems to be an issue with vim-bundler and the ~system call~ shell command to get ruby ABI version. I see the same strange characters (well, just the last few of them actually) when starting vim from a rails project without providing a file to edit, with both vim-rails and vim-bundler installed.

If I comment out the ~system call~ shell command and hard-code the value of gem_paths in bundler.vim to the known value the weird characters don't appear, i.e.

index 45c2e44..8446f72 100644
--- a/plugin/bundler.vim
+++ b/plugin/bundler.vim
@@ -395,7 +395,8 @@ function! s:project_paths(...) dict abort
       exe chdir s:fnameescape(self.real())

       if empty(gem_paths)
-        let gem_paths = split(system(prefix.'ruby -rrbconfig -rrubygems -e '.s:shellesc('print(([RbConfig::CONFIG["ruby_version"]] + Gem.path).join(%(;)))')), ';')
+        " let gem_paths = split(system(prefix.'ruby -rrbconfig -rrubygems -e '.s:shellesc('print(([RbConfig::CONFIG["ruby_version"]] + Gem.path).join(%(;)))')), ';')
+        let gem_paths = ['2.6.0', '/Users/mwoods/.gem/ruby/2.6.0', '/Users/mwoods/.rbenv/gems/2.6.0']

         let abi_version = empty(gem_paths) ? '' : remove(gem_paths, 0)
       else```

mmrwoods avatar Oct 18 '21 15:10 mmrwoods

Does this happen with any system() call? If you add call system('true'), to your vimrc, does that also cause the problem?

tpope avatar Oct 18 '21 15:10 tpope

No, adding call system('true') to vimrc does not cause the same problem, but if I add it to bundler.vim it does, weird!

index 45c2e44..e07c007 100644
--- a/plugin/bundler.vim
+++ b/plugin/bundler.vim
@@ -395,7 +395,9 @@ function! s:project_paths(...) dict abort
       exe chdir s:fnameescape(self.real())
 
       if empty(gem_paths)
-        let gem_paths = split(system(prefix.'ruby -rrbconfig -rrubygems -e '.s:shellesc('print(([RbConfig::CONFIG["ruby_version"]] + Gem.path).join(%(;)))')), ';')
+        call system('true')
+        " let gem_paths = split(system(prefix.'ruby -rrbconfig -rrubygems -e '.s:shellesc('print(([RbConfig::CONFIG["ruby_version"]] + Gem.path).join(%(;)))')), ';')
+        let gem_paths = ['2.6.0', '/Users/mwoods/.gem/ruby/2.6.0', '/Users/mwoods/.rbenv/gems/2.6.0']
 
         let abi_version = empty(gem_paths) ? '' : remove(gem_paths, 0)
       else

mmrwoods avatar Oct 18 '21 15:10 mmrwoods

Ok, so this seems to be some vim weirdness... adding a call to system('true') within any function triggered during vim startup seems to do the trick, whether in bundler.vim or vimrc

mmrwoods avatar Oct 18 '21 15:10 mmrwoods

Might be a bad shell config. Try set shell=/bin/sh shellcmdflag=-c in your vimrc to eliminate some common offenders.

tpope avatar Oct 18 '21 15:10 tpope

Sticking this at the bottom of my vimrc causes similar garbage to be written to the screen:

function! <sid>foo()
  call system('true')
endfunction
autocmd VimEnter * call <sid>foo()

mmrwoods avatar Oct 18 '21 15:10 mmrwoods

Adding set shell=/bin/sh shellcmdflag=-c to vimrc, before calling system() doesn't help unfortunately, but at least it seems clear this is not an issue with vim-bundler :-)

mmrwoods avatar Oct 18 '21 15:10 mmrwoods

It could be worked around by using jobs, which would be an improvement anyways, but it will take more than a one-liner.

tpope avatar Oct 18 '21 15:10 tpope