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

Add :silent in xolox#misc#os#is_mac() to prevent junk on terminal. #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drmikehenry
Copy link

The function xolox#misc#os#is_mac() uses Vim's system() function to
invoke uname for platform detection. By default, Vim's system()
function sets the terminal to "cooked" mode during execution of the
external program. Normally this would not be a problem, but there are
some sensitive moments during Vim startup where terminal settings are
being negotiated; at these times, changing to "cooked" mode can disrupt
this negotiation.

In particular, the vim-session plugin uses this is_mac() function
during a VimEnter auto-command. When processing VimEnter, terminals
such as Kitty are in the midst of terminal negotiations. The visible
effect is that escape sequences such as the below may end up on screen
after invoking vim with no arguments:

^[[2;2R^[[3;1R^[[>1;4000;20c^[]10;rgb:dddd/dddd/dddd^[^[]11;rgb:0000/0000/0000^[\

To avoid this, use :silent with system() as recommended in
:help system().

This problem can be demonstrated in complete isolation from any plugins
by having an empty ~/.vim directory and the below three lines as the
sole contents of ~/.vimrc:

augroup Something
au VimEnter * call system("true", "")
augroup END

Using Kitty, the above will reliable generate the junk characters shown
above when invoking vim with no arguments.

The function `xolox#misc#os#is_mac()` uses Vim's `system()` function to
invoke `uname` for platform detection.  By default, Vim's `system()`
function sets the terminal to "cooked" mode during execution of the
external program.  Normally this would not be a problem, but there are
some sensitive moments during Vim startup where terminal settings are
being negotiated; at these times, changing to "cooked" mode can disrupt
this negotiation.

In particular, the vim-session plugin uses this `is_mac()` function
during a `VimEnter` auto-command.  When processing `VimEnter`, terminals
such as Kitty are in the midst of terminal negotiations.  The visible
effect is that escape sequences such as the below may end up on screen
after invoking `vim` with no arguments:

  ^[[2;2R^[[3;1R^[[>1;4000;20c^[]10;rgb:dddd/dddd/dddd^[\^[]11;rgb:0000/0000/0000^[\

To avoid this, use `:silent` with `system()` as recommended in
`:help system()`.

This problem can be demonstrated in complete isolation from any plugins
by having an empty `~/.vim` directory and the below three lines as the
sole contents of `~/.vimrc`:

  augroup Something
  au VimEnter * call system("true", "")
  augroup END

Using Kitty, the above will reliable generate the junk characters shown
above when invoking `vim` with no arguments.
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

Successfully merging this pull request may close these issues.

1 participant