Skip to content

Screen corruption with neovim #1041

Open

Description

@theseanl
Screenshot with mosh

61B30CA7-3ECE-4109-9DF5-8D4EE80107A9

Screenshot with ssh

5F6707CB-D192-436D-8711-A800515ED0E4

I’m running mosh server built from master on Amazon Linux AMI. For a client, I’ve used iOS apps “blink” and “termius”. I can reproduce above results stably on both of the clients — note that how the start of a 3rd wrapped line is dedented.
Maybe it is a bug of my configuration, if so any help on the configuration would be appreciated.

Activity

  1. theseanl commented on Jul 7, 2019

    @theseanl
    Author

    SCRIPTFILE.txt
    Here is a script output recorded while reproducing the issue. Any pointer to debug would be greatly appreciated.

  2. djsavvy commented on Jul 7, 2020

    @djsavvy

    I’ve also been having similar screen corruption issues in neovim. At this point I’ve spent a couple of hours cumulatively trying to fix this, and I finally have a (hackish) workaround.

    On my server’s .zshrc, I have the following line:

    alias vim="TERM=st nvim" 
    

    When using st for the value of $TERM, Neovim doesn’t mess up the indentation of soft-wrapped lines.

    Despite this workaround, I’d really prefer if mosh natively solved this.

  3. dwoodwor-intel commented on Sep 9, 2022

    @dwoodwor-intel

    I've also been having this problem, but TERM=st (and TERM=xterm-basic) did not fix it for me. TERM=ansi did fix it, but was missing a few features that I use like 256-color support. I compared the ansi and xterm-basic terminfo and narrowed down the differences until I found the part that causes the neovim screen corruption: character set control sequences in sgr (%?%p9%t\E(0%e\E(B%;). I was able to make a new mosh profile as a workaround by removing these sequences and it seems to be working for me:

    $ cat mosh.ti
    mosh|less buggy mosh profile with character set control sequences removed from sgr,
            sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
            use=xterm-256color,
    $ tic mosh.ti
    $ TERM=mosh nvim
    

    It would be nice if mosh was able to handle these sequences more gracefully if it's going to set TERM=xterm though.

  4. keithw commented on Sep 26, 2022

    @keithw
    Member

    Mosh supports C1 controls, but is locked to Unicode only -- it doesn't support ISO 2022 charset-switching sequences on purpose. (See #1127 (comment) for a longer rationale.) neovim should be using Unicode (ISO 10646) characters when the terminal charset is Unicode and NCURSES_NO_UTF8_ACS is set, rather than ISO 2022 locking shifts into an alternate charset.

  5. yyb196 commented on Aug 1, 2023

    @yyb196

    @keithw thanks for your explanation, but how can I found out which char/icon in my neovim config file or in my neovim plugin file incur this corruption.

  6. julienmarie commented on Mar 15, 2024

    @julienmarie

    So this means it wont get fixed ? Neovim is one of the most important terminal programs out there.

  7. ProducerMatt commented on Jun 24, 2024

    @ProducerMatt

    Just to show how nasty this corruption can get. Scenarios like this render it basically unusable. https://youtu.be/4ySMoZWfEgM

  8. bergheim commented on Jun 24, 2024

    @bergheim

    I get the same kind of corruption @ProducerMatt. Both vim and emacs.

  9. hexacera commented on Jul 16, 2024

    @hexacera

    This issue disappears when I disable lualine.nvim, and consistently reproduces when I re-enable lualine. Maybe some characters or escape sequences from lualine has been causing the issue?

    Can the other commenters share whether you are using lualine (or some other *line plugins)?

    Found a related issue in the lualine repo: Bug: when running mosh with neovim and lualine, terminal is broken #1199

  10. dwoodwor-intel commented on Jul 16, 2024

    @dwoodwor-intel

    I wasn't using a *line plugin back when I was using mosh and encountered this issue, so the problem isn't specific to those

  11. meinside commented on Oct 23, 2024

    @meinside

    I apologize for resurrecting this old issue and adding a seemingly unhelpful '+1', but I'm glad to know I'm not alone in experiencing this problem.

    For years, I've been plagued by randomly broken characters in neovim, but I had no idea what was the cause, so it became a 'normal' part of my neovim experience. And today, just before finding this issue, I discovered that the problem only occurs with mosh connections, not with ssh connections or local terminals.

    While I can work via ssh or locally for now, I'd be really happy it if it could be resolved.

  12. vodrazka commented on Apr 5, 2025

    @vodrazka

    Anyone having a good workaround? I'm using mosh from Blink on iPadOS.

  13. meinside commented on Apr 11, 2025

    @meinside

    It's been several days since my remote mosh screens stopped getting corrupted while using neovim,
    but I'm not sure what made the change and if it affects anyone else.

    My host machine is macOS 15.4 (24E248) with kitty 0.41.1 and mosh 1.4.0 [build mosh 1.4.0],
    and affected machines are:

    • Linux 6.6.63-v8+ (aarch64) / Debian GLIBC 2.31-13+rpt2+rpi1+deb11u11 / NVIM v0.11.0
    • Linux 6.8.0-1023-oracle (aarch64) / Ubuntu GLIBC 2.39-0ubuntu8.4 / NVIM v0.12.0-dev-114+g51a967d58a
    • and alikes.

    I've been using lualine.nvim through lazyvim, but I cannot tell if there was any related fix for this issue in its repository.

  14. SichangHe commented on May 30, 2025

    @SichangHe

    Could you provide your env, @meinside? Neovim is all over the place for me whenever termguicolors is on.

  15. jdrouhard commented on Aug 20, 2025

    @jdrouhard

    I think I fixed the source of a lot of screen corruption/rendering issues in my fork. Can you all test it out and see if it's any better? Can't guarantee it gets them all, but it certainly eradicated the ones I was seeing.

    https://github.com/jdrouhard/mosh

  16. achernya commented on Aug 20, 2025

    @achernya
    Collaborator

    Is the fix just b31161a? If so, that looks straightforward to test and merge.

  17. jdrouhard commented on Aug 20, 2025

    @jdrouhard

    Is the fix just b31161a? If so, that looks straightforward to test and merge.

    Yes, it was basically a one liner.

    I noticed massive screen corruption whenever I used neovim's :checkhealth which has a few warning triangle emojis in it. Tracked it down to this unique combining character which essentially transforms the glyph into its emoji representation, and ends up increasing the width to 2 as a result. Neovim has similar special logic for 0xFE0F to increase the width when it's detected (though it also requires the glyph to be an actual pictogram as well, which my one liner does not do).

    I don't know if this alone is going to fix all the screen corruption reported in this issue but it certainly helped the case I was seeing.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions