Skip to content

Garbage appears in the buffer at startup #19666

Closed

Description

@h-east

Steps to reproduce

The reproduction procedure has not yet been established. I'm currently working on establishing a procedure.
When Vim starts, garbage characters sometimes appear at the beginning of the buffer.
Pattern 1: ;2$y^[[?2048;0$y^[[?12;2$y
Pattern 2: ^[[3;1R^[[>0;10;1c^[]10;rgb:cccc/cccc/cccc^[\^[]11;rgb:0c0c/0c0c/0c0c^[\^[[?2026;2$y^[[?2048;0$y^[[?12;2$y

The garbage may appear only briefly, or it may remain. (It can be cleared with CTRL-L)
It is likely a response to terminal requests \033[?2026$p (sync) and \033[?2048$p (win resize).

It is not certain, but it may be related to the execution of system() in .vimrc when Vim starts.

Expected behaviour

Garbage not appears.

Version of Vim

9.2.0148

Environment

Ubuntu 24.04.4 LTS
Windows Terminal 1.23.20211.0
TERM=xterm-256color

Logs and stack traces

None.

Activity

  1. h-east commented on Mar 13, 2026

    @h-east
    ContributorAuthor
  2. 64-bitman commented on Mar 13, 2026

    @64-bitman
    Member

    I cannot reproduce, does this happen when run with --clean? If it doesn't can you share your vimrc? Thanks

  3. h-east commented on Mar 13, 2026

    @h-east
    ContributorAuthor

    tabline_example_bad.vim

    vim9script
    
    set showtabline=2
    if has("gui_running")
    endif
    &tabline = "%!MyTabLine()"
    def g:MyTabLine(): string
      var tabpages_info = ''
      if tabpagenr('$') > 1
        tabpages_info = $"%#TabLine#[{tabpagenr()}/{tabpagenr('$')}]%#TabLineFill# "
      endif
      return $"{tabpages_info}cwd: {fnamemodify(getcwd(), ":~")} {GitStatus()}"
    enddef
    
    def GitStatus(): string
      var branch = system('git branch --show-current 2>/dev/null')
      if v:shell_error != 0
        return ''
      endif
      branch = substitute(branch, '\n', '', 'g')
      var dirty = system('git status --porcelain -uno 2>/dev/null') !=# '' ? ' *' : ''
      return $'({branch}{dirty})'
    enddef
    
    # vim: set et ts=2 sw=2 tw=78:

    Executing the following will prevent the garbage from remaining indefinitely, but it will briefly appear on the first line of the buffer (the line after the tabline).

    $ vim --clean -S tabline_example_bad.vim
  4. o-sdn-o commented on Mar 13, 2026

    @o-sdn-o

    Environment

    Ubuntu 24.04.4 LTS
    Windows Terminal 1.23.20211.0

    @h-east I suspect this may be related to a bug in Win32-OpenSSH. Are you using Win32-OpenSSH to connect to Ubuntu?

  5. h-east commented on Mar 13, 2026

    @h-east
    ContributorAuthor

    I suspect this may be related to a bug in Win32-OpenSSH. Are you using Win32-OpenSSH to connect to Ubuntu?

    >ssh -V
    OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
    
  6. o-sdn-o commented on Mar 13, 2026

    @o-sdn-o

    The Win32-OpenSSH release with the fix hasn't been published yet, so it might be worth building it from source (it's fixed there) and seeing how it goes. Building ssh.exe should be enough.

  7. h-east commented on Mar 15, 2026

    @h-east
    ContributorAuthor

    Following the instructions in Commit 751b59e I added :silent to the system() call and the problem disappeared.
    Thank you @mattn 👍

    diff --git a/tabline_example_bad_old.vim b/tabline_example_bad.vim
    index 9da6ff8..8ea1491 100644
    --- a/tabline_example_bad_old.vim
    +++ b/tabline_example_bad.vim
    @@ -14,12 +14,12 @@ def g:MyTabLine(): string
     enddef
     
     def GitStatus(): string
    -  var branch = system('git branch --show-current 2>/dev/null')
    +  silent var branch = system('git branch --show-current 2>/dev/null')
       if v:shell_error != 0
         return ''
       endif
       branch = substitute(branch, '\n', '', 'g')
    -  var dirty = system('git status --porcelain -uno 2>/dev/null') !=# '' ? ' *' : ''
    +  silent var dirty = system('git status --porcelain -uno 2>/dev/null') !=# '' ? ' *' : ''
       return $'({branch}{dirty})'
     enddef
     
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions