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

strange text at the top of vim when starting it #579

Open
bsylvain opened this issue Jun 17, 2021 · 13 comments
Open

strange text at the top of vim when starting it #579

bsylvain opened this issue Jun 17, 2021 · 13 comments

Comments

@bsylvain
Copy link

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.

@tpope
Copy link
Owner

tpope commented Jun 17, 2021

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.

@clowder
Copy link

clowder commented Sep 30, 2021

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?!


@tpope
Copy link
Owner

tpope commented Sep 30, 2021

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

@clowder
Copy link

clowder commented Oct 1, 2021

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:

vim-rails/autoload/rails.vim

Lines 2804 to 2806 in 03a5c3e

for [name, command] in items(rails#app().commands())
call s:define_navcommand(name, command)
endfor

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?

@tpope
Copy link
Owner

tpope commented Oct 1, 2021

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.

@mmrwoods
Copy link

mmrwoods commented Oct 18, 2021

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```

@tpope
Copy link
Owner

tpope commented Oct 18, 2021

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

@mmrwoods
Copy link

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
Copy link

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

@tpope
Copy link
Owner

tpope commented Oct 18, 2021

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

@mmrwoods
Copy link

mmrwoods commented Oct 18, 2021

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
Copy link

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

@tpope
Copy link
Owner

tpope commented Oct 18, 2021

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

mmrwoods added a commit to mmrwoods/dotfiles that referenced this issue Dec 2, 2021
Running shell commands via a call to system() within a user defined
function on vim startup causes weird text to be written to the screen,
on MacOS/bash/iTerm. See tpope/vim-rails#579

At some point I'll probably delve into this some more and try to find
the root cause, but for now just work around it by disabling running
both rails and projectionist VimEnter autocmds which trigger the issue.
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

4 participants