Thursday, July 23, 2020

Re: Vim Display Corruption

Folks,

After almost two years, I may have stumbled onto the root cause of this vi display corruption problem.

It looks to be related to the character encoding difference between the Linux system that uses UTF-8, and macOS (XQuartz) (X11) which apparently uses something else.

I solved this problem by starting my xterm sessions on macOS with this xterm command option:

-en UTF-8

and removed all other work-arounds on macOS and the Linux systems.

Now the vi edit display on macOS is no longer corrupted.

The key seems to be the the encoding difference seen on macOS as:

Riegner-iMac3:HPE dick$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

And that on one of our typical Linux systems:

linux-pu89:/dickie/text/$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

The root cause seems to be the extended non-ASCII characters in the text file. This solution does not handle all the extended non-ASCII characters exactly the same on macOS and Linux.

For example, on my local Linux xterm, the Linux vi shows the correct text for the local file:

491 If it's not logged in, then login as:

But on my macOS xterm, looking remotely at the same file on Linux, the Linux vi shows that the quote is missing; so vi displaying from Linux back to macOS is close, but not exact:

491 If it s not logged in, then login as:

I copied the Linux file locally to macOS and used the macOS version of vi to display the non-ASCII characters as hex using "set display=uhex":

491 If it <80><99>s not logged in, then login as:

So there are definitely extended non-ASCII characters in this text file contributing to the macOS, Linux, and vi confusion.

Another option is to set the macOS locale environment variables, but I do not know what side-effects and problems that may cause. So I am going with this macOS (XQuartz) (X11) solution:

xterm -en UTF-8

None of the vi display corruption is seen using the macOS Terminal application. This sure looks to be a macOS (XQuartz) (X11) issue, but vi is front-and-center when the display corruption is seen.

I hope this solution turns out to be solid and helps other vi users running XQuartz on macOS.

--
Dick Riegner
dickie@nuveramail.net
--

>
>
>
> I consistently see text display corruption when
> editing a file on a remote Linux system with vim.
>
> I run an xterm window on macOS and ssh into a
> remote Linux machine. The edit session is
> displayed back to an XQuartz server running on
> the same macOS.
>
> I have only seen this problem when displaying
> back to an XQuartz server running on macOS.
>
> I have not seen the problem when displaying back
> to an X11 server running on various Linux
> systems.
>
> This problem occurs with newer versions of vim,
> but not older versions.
>
> Inserting lines causes the INSERT message to be
> displayed in the command line, but it is not
> cleared after hitting the ESC key.
>
> Inserting text also causes extraneous lines of
> text to be added to the body of the original
> text, corrupting the edit display.
>
> I suspect that I am seeing the same vim behavior
> as was reported in this incident:
>
> https://groups.google.com/forum/#!topic/vim_dev/GR9YG8TZy6o
>
> A work-around is to add this statement to the
> .vimrc file:
>
> set ambiwidth=single
>
> I do not know if this is a bug in vim, XQuartz,
> or both. So I am asking for vim help here and
> XQuartz help in another forum.
>
> Here is a summary of editing a file using two
> versions of vim, each with and without, the
> ambiwidth work-around.
>
>
> New Vim
> -------
> VIM - Vi IMproved 7.4 (2013 Aug 10)
> Included patches: 1-207, 209-326
> Compiled by 'http://www.opensuse.org/'
>
> Works with: set ambiwidth=single
> Fails without: set ambiwidth=single
>
>
> Old Vim
> -------
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 4 2012 09:50:29)
> Included patches: 1-108
> Compiled by 'http://www.opensuse.org/'
>
> Works with: set ambiwidth=single
> Works without: set ambiwidth=single
>
> --
>
> Dick Riegner
>
>
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/d52c5346-fe28-9b9d-b5c3-8561b44dcb17%40nuveramail.net.

No comments: