mobile-shell / mosh

Mobile Shell
https://mosh.org
GNU General Public License v3.0
12.56k stars 730 forks source link

Terminal corruption with emacs-over-mosh #909

Open briansniffen opened 7 years ago

briansniffen commented 7 years ago

I'm using mosh 1.3.2 to connect to a mosh 1.2.6 (Debian Stable) server. When using Emacs (24.5.1) with long, truncated lines in one buffer and visual-wrap in other buffers (the notmuch mail client), I get visual corruption: text that should be cleared is put in the first line, the mode line gets screwed up, and similar.

I don't get such corruption connecting to the same tmux session over ssh. I get the corruption both in iTerm2 and in Terminal.app. I don't think I saw that corruption in mosh 1.3.0. I originally observed it with tmux 2.3 in the mix, but have replicated it without tmux.

How can I help debug this?

keithw commented 7 years ago

Our #1 cause of this kind of corruption is when the client and server C libraries disagree about the wcwidth of a Unicode character -- is it possible there are any recent-version Unicode characters (e.g. new emoji) in the mix here?

If the problem can be replicated without tmux, could you please attach script output captured (1) just outside emacs, and then another script captured simultaneously from (2) just outside mosh?

llllvvuu commented 7 years ago

I think you're right about the wcwidth disagreement thing. Chiming in because I can get corruption in vim-over-mosh in iTerm2 with Unicode 9 widths enabled (just open a new buffer and paste in some 🔥🔥🔥), but it looks fine with Unicode 8 widths enabled (which has some incorrect widths, allowing emojis to overlap but is more agreeable with most programs - zsh, mosh, fish all have trouble with the Unicode 9 widths)

tidux commented 6 years ago

I get an outright crash and failure to launch emacsclient when using zsh as the calling shell, but not bash or ksh93:

*ERROR*: Unknown command: NCURSES_NO_UTF8_ACS=1

There are no high-unicode values in my zsh $PROMPT variable. I suspect Emacs is reading to the first blank line in the environment variable set before interpreting as commands, and mosh is injecting a newline there:

...
LANG=en_US.UTF-8
SHLVL=1
PWD=/home/tidux
OLDPWD=/home/tidux
_=/usr/bin/env

NCURSES_NO_UTF8_ACS=1
HISTFILE=/home/tidux/.zsh_history
...
keithw commented 6 years ago

This seems like a pretty different issue than the above (which was about terminal corruption). Can you please file a new issue?

tidux commented 6 years ago

Actually, on further inspection, it seems to be related to a longstanding bug in Gtk3 that impacts Emacs run in client/server mode. Emacs compiled against the Lucid X11 toolkit does not display this bug. Please disregard.