XQuartz icon indicating copy to clipboard operation
XQuartz copied to clipboard

scrolling (ctrl-F) in vim broken when running from an xterm under twm

Open PensadorDave opened this issue 4 years ago • 28 comments

XQuartz 2.8.0 beta 3 caused scrolling (ctrl-F) to break in vim when running from an xterm under twm. The displayed lines are mangled and blank lines are removed. Also, the status line does not clear when executing a : command in vim. The same /usr/bin/vim works fine when running from a native Terminal under macOS.

PensadorDave avatar Feb 04 '21 14:02 PensadorDave

Can you isolate what is the primary change here that caused the issue?

Can you try backing up the 2.7.11 server and xterm binaries, installing 2.8.0 (for the updated client stack) and trying:

2.7.11 XQuartz.app + 2.7.11 xterm 2.7.11 XQuartz.app + 2.8 xterm 2.8 XQuartz.app + 2.7.11 xterm

That should help isolate the issue as a server, app, or library problem.

jeremyhu avatar Feb 05 '21 06:02 jeremyhu

@PensadorDave Could you please provide that regression information? Thanks.

jeremyhu avatar Feb 16 '21 07:02 jeremyhu

I'm unable to reproduce this (and am not a vim user, so maybe I'm missing something). EIther way, closing due to lack of additional information, sorry.

jeremyhu avatar Feb 17 '21 05:02 jeremyhu

I live in Austin TX, currently being hit with severe winter weather.  My house has been without power for most of the last 5 days.  I will provide regression and other information as soon as I can download the latest macOS beta.  The city is unable to say when power might be restored to my house.  So we should be patient.

Thank you,

On 2/16/21 1:00 AM, Jeremy Huddleston Sequoia wrote:

@PensadorDave https://github.com/PensadorDave Could you please provide that regression information? Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-779631719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBYPUZFNN7MSOT7MUHB7UDS7IJYLANCNFSM4XC7FZAA.

PensadorDave avatar Feb 17 '21 14:02 PensadorDave

Ok, thanks. Reopening this for tracking. Stay warm!

jeremyhu avatar Feb 17 '21 20:02 jeremyhu

Note that 2.8.0_beta4 includes xterm-366 (compared to version 363 in the earlier betas). Worth checking out.

jeremyhu avatar Feb 17 '21 21:02 jeremyhu

Hi Jeremy,

I have a much better idea now of what is going on.  I'll try to summarize briefly what I have found.

There is an easy workaround, but the workaround is a little inconvenient for the user.  The ultimate fix may have to do with how vim is being compiled and linked by Apple.

The vim problem (#59) is very repeatable and easy to reproduce.  But it does take some experience with vim to see it happening.  The problem only occurs in an xterm that has been initiated by XQuartz (latest betas).  I now have a pretty good idea of why, which I will explain.  The problem does not occur in Apple's Terminal app.  I believe this is true because the Terminal app explictly sets the term option, by selecting the appropriate xterm in the Preferences (Terminal --> Profiles --> Advanced).  The problem does not depend on twm.  I can still see the problem when .xinitrc is not used.  If the XQuartz Application Terminal is selected, and then vim (or vi, which is a link to vim) is run, then the problem can be manifested.

One thing that confused me is that $ ls -l which vi gives "lrwxr-xr-x  1 root  wheel  3 Jan  1  2020 ./vi@ -> vim", which suggests that the vim executable was not recompiled for either your latest beta or the macOS latest beta.  However, when you do :version in vim, you will see that the executable was compiled on Feb 7, 2021, which suggests that it was recompiled by Apple for its latest betas.  I don't understand the discrepancy in the dates.  But at least now I believe that it is this newer version of vim which is causing the problem.

The workaround is this: In vim, run :set term=xterm, or :set term=xterm-256color, or whatever xterm you like.  For some reason, which I am currently trying to figure out, explicitly setting the term fixes the problem.  But putting "set term=xterm" in the .vimrc file does not fix the problem.  I think that explicitly setting term in vim causes other good things to happen, whereas doing it in .vimrc does not.  I don't understand why.

If I had the source code for vim and other components, I might be able to figure out the problem.  But unfortunately, I can't afford to spend that much time on the problem.  Also, I suspect that the problem might go away in later betas of Big Sur.  It definitely is not happening in Big Sur 11.2.  I reported the problem because I didn't want to see this problem find its way in to Big Sur 11.3 RC or later.

If you need me to explain how to reproduce the problem in vim, I can do that rather easily, if that will help.

I've enjoyed working on this project, and I'd be willing to lend a hand in this or future problems, especially involving vim, twm, xterm, and related issues.  I use these tools in my daily work.

Let me know any next steps that you would suggest for me.  Also, if you want to close the bug, I'd be okay with that.  Without a lot more work, I'm not sure that you can fix the problem on the XQuartz end.  If I make any more progress, I will let you know.

Thanks,

-Dave

P.S. The problem occurred for both xterm-366 and xterm-363, but I don't think the xterm executable is the cause of the problem.

On 2/17/21 3:16 PM, Jeremy Huddleston Sequoia wrote:

Note that 2.8.0_beta4 includes xterm-366 (compared to version 363 in the earlier betas). Worth checking out.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-780858922, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBYPU6GXROC6VOPGYJI7IDS7QWZLANCNFSM4XC7FZAA.

PensadorDave avatar Feb 20 '21 19:02 PensadorDave

Thanks, Dave.

Would you mind sending this report over via https://feedbackassistant.apple.com and reporting back the FB number here, so I can link the issues and evangelize it internally?

Given this, I'm moving this out of the 1.8 tracker but will try to get to the bottom of it.

jeremyhu avatar Feb 21 '21 22:02 jeremyhu

Jeremy,

I have created  feedbackassistant.apple.com/feedback/9015947, which includes a few bits of additional information that I have found.  I found another workaround, and I believe that this is either a bug in vim or in one of the many resource files for vim.

In particular, if you invoke vim using $ vim -u NONE file.txt, then the problems are gone.  The -u flag forces vim NOT to read any resource files.  Then the bug is gone.  Of course that is not a good solution, but it indicates that the problem is either in the resource files, or in vim itself.  $ vim -V file.txt is verbose mode, which, among other things, shows the resource files being read (there are many).

Thanks,

-Dave

On 2/21/21 4:58 PM, Jeremy Huddleston Sequoia wrote:

Thanks, Dave.

Would you mind sending this report over via https://feedbackassistant.apple.com https://feedbackassistant.apple.com and reporting back the FB number here, so I can link the issues and evangelize it internally?

Given this, I'm moving this out of the 1.8 tracker but will try to get to the bottom of it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-782943930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBYPU5KB5NKYYBEYZ2O52LTAGFZ3ANCNFSM4XC7FZAA.

PensadorDave avatar Feb 22 '21 18:02 PensadorDave

rdar://74600690

jeremyhu avatar Feb 23 '21 00:02 jeremyhu

I use vi/vim all the time and Ihave the same problem reported by PensadorDave, even though I am running OS 11.4 . My version: XQuartz 2.8.1 (xorg-server 1.20.11). His suggested fix (:set term=xterm) works for me also, but this is a big nuissance having to run this command each time I open a vi session (which is very often). Why hastn't this been already fixed by Apple?

gkoenigsberger avatar Sep 27 '21 14:09 gkoenigsberger

So far, nobody but me (PensadorDave) has reported being able to reproduce the problem, so I appeciate seeing your email.

I don't believe that the problem is in vim, since vim works fine in Term and iTerm2.  I don't know if the problem only happens in TWM running in XQuartz.  However, no amount of changing settings in .twmrc, .vimrc, .xinitrc, etc., makes the problem go away, and strangely, as gkoenigberger notes, and I originally reported, only by (:set term=xterm) in vim seems to fix the problem.  I'm speculating that the problem is in XQuartz, and that Apple will never reproduce the problem unless they are running vim under TWM (or possibly other window managers, which I haven't tried) under XQuartz.

How can we escalate the problem to the right people?  (I'm obviously not the right person to fix the problem.)

-Dave Johnson (PensadorDave)

On 9/27/21 9:41 AM, gkoenigsberger wrote:

I use vi/vim all the time and Ihave the same problem reported by PensadorDave, even though I am running OS 11.4 . My version: XQuartz 2.8.1 (xorg-server 1.20.11). His suggested fix (:set term=xterm) works for me also, but this is a big nuissance having to run this command each time I open a vi session (which is very often). Why hastn't this been already fixed by Apple?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-927941856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBYPUZJTIZS367PC45GAN3UEB7DJANCNFSM4XC7FZAA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

PensadorDave avatar Sep 27 '21 15:09 PensadorDave

Hi Dave,

Thank you for the prompt reply. I've been running quite old OS on my Mac's because of software compatibility issues and, unlike other people, I'm totally incompetent to try to fix these. Now that I was forced to upgrade to 11.4, the last thing I expected to find was a problem with functions such as vi!

I would think it is pretty easy to reproduce the problem. All they (whoever is responsible) have to do is:

  1. open an xterm of the kind that XQuartz provides;
  2. type: vi some_text_file.txt
  3. try searching for a word in that text, and see what happens; also, try editing a line or two and try reading the result.

I'm assuming that a copy of this is going to the XQuartz people ......

Thanks again! Gloria

On Mon, Sep 27, 2021 at 11:01 AM Dave Johnson @.***> wrote:

So far, nobody but me (PensadorDave) has reported being able to reproduce the problem, so I appeciate seeing your email.

I don't believe that the problem is in vim, since vim works fine in Term and iTerm2. I don't know if the problem only happens in TWM running in XQuartz. However, no amount of changing settings in .twmrc, .vimrc, .xinitrc, etc., makes the problem go away, and strangely, as gkoenigberger notes, and I originally reported, only by (:set term=xterm) in vim seems to fix the problem. I'm speculating that the problem is in XQuartz, and that Apple will never reproduce the problem unless they are running vim under TWM (or possibly other window managers, which I haven't tried) under XQuartz.

How can we escalate the problem to the right people? (I'm obviously not the right person to fix the problem.)

-Dave Johnson (PensadorDave)

On 9/27/21 9:41 AM, gkoenigsberger wrote:

I use vi/vim all the time and Ihave the same problem reported by PensadorDave, even though I am running OS 11.4 . My version: XQuartz 2.8.1 (xorg-server 1.20.11). His suggested fix (:set term=xterm) works for me also, but this is a big nuissance having to run this command each time I open a vi session (which is very often). Why hastn't this been already fixed by Apple?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/XQuartz/XQuartz/issues/59#issuecomment-927941856>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHBYPUZJTIZS367PC45GAN3UEB7DJANCNFSM4XC7FZAA . Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-927959789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJEFYNLMJVJTWCL6BFTUECBMVANCNFSM4XC7FZAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gkoenigsberger avatar Sep 27 '21 15:09 gkoenigsberger

I see this problem with OS 11.6 and Xquartz 2.8.1

kddevin avatar Oct 06 '21 22:10 kddevin

I backed down to Xquartz 2.7.11 and saw the same problem. Oddly, an xterm launched from the Terminal utility worked fine. I compared the environments in xterm windows launched from Terminal and from Xquartz. Setting environment variable LANG=C in the Xquartz window fixed the problem.

kddevin avatar Oct 06 '21 23:10 kddevin

What exactly do I have to do to set the environment variable LANG=C in the Xquartz window?

On Wed, Oct 6, 2021 at 7:30 PM K Devine @.***> wrote:

I backed down to Xquartz 2.7.11 and saw the same problem. Oddly, an xterm launched from the Terminal utility worked fine. I compared the environments in xterm windows launched from Terminal and from Xquartz. Setting environment variable LANG=C in the Xquartz window fixed the problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-937322545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJBYVDLY7PH2V6I43DDUFTLXVANCNFSM4XC7FZAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gkoenigsberger avatar Oct 07 '21 00:10 gkoenigsberger

I use vi/vim all the time and Ihave the same problem reported by PensadorDave, even though I am running OS 11.4 . My version: XQuartz 2.8.1 (xorg-server 1.20.11). His suggested fix (:set term=xterm) works for me also, but this is a big nuissance having to run this command each time I open a vi session (which is very often). Why hastn't this been already fixed by Apple?

It's a bug in vim or xterm. Apple just shipped newer vim which is why you're seeing this with newer versions of macOS or with newer vim running on older macOS.

jeremyhu avatar Oct 07 '21 04:10 jeremyhu

What exactly do I have to do to set the environment variable LANG=C in the Xquartz window?

$ export LANG=C
$ vim

jeremyhu avatar Oct 07 '21 04:10 jeremyhu

This helps. Thank you!

On Thu, Oct 7, 2021 at 12:37 AM Jeremy Huddleston Sequoia < @.***> wrote:

What exactly do I have to do to set the environment variable LANG=C in the Xquartz window?

$ export LANG=C $ vim

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-937438743, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJH5O4EDQHXZDLMCHZLUFUPYBANCNFSM4XC7FZAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gkoenigsberger avatar Oct 07 '21 12:10 gkoenigsberger

You're welcome. Happy to help!

kddevin avatar Oct 07 '21 16:10 kddevin

Just another user here with the same problem.

Putting the terminal definition in my .vim/vimrc file and it does not fix the issue, as above. (That is, adding "set term=xterm" in my ~/.vim/vimrc file.) Writing it on the vim terminal each time does fix it but that's annoying.

Putting "export LANG=C" in my .bash_profile does make it go away. I am doing this in conjunction with setting the term in my ~/.vim/vimrc file so I don't know if both are necessary.

Thanks Steve

stevevanhooser avatar Jan 14 '22 14:01 stevevanhooser

It hasn't been fixed yet. My new MacBook Pro (arm64) has the same problem. The workaround setenv LANG C (under tcsh) works, but shouldn't be necessary.

brucerjulian avatar Jul 19 '22 14:07 brucerjulian

Thanks for the update. One would think that they could have fixed this by now.

On Tue, Jul 19, 2022 at 9:43 AM brucerjulian @.***> wrote:

It hasn't been fixed yet. My new MacBook Pro (arm64) has the same problem. The workaround setenv LANG C (under tcsh) works, but shouldn't be necessary.

— Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-1189143211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJDJM6CFWDJH2AGAIF3VU25HHANCNFSM4XC7FZAA . You are receiving this because you commented.Message ID: @.***>

gkoenigsberger avatar Jul 19 '22 15:07 gkoenigsberger

Amen.

On Jul 19, 2022, at 4:19 PM, gkoenigsberger @.***> wrote:

Thanks for the update. One would think that they could have fixed this by now.

On Tue, Jul 19, 2022 at 9:43 AM brucerjulian @.***> wrote:

It hasn't been fixed yet. My new MacBook Pro (arm64) has the same problem. The workaround setenv LANG C (under tcsh) works, but shouldn't be necessary.

— Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-1189143211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJDJM6CFWDJH2AGAIF3VU25HHANCNFSM4XC7FZAA . You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-1189186243, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2EH7TLUWZFLA36SEEONDSDVU3BQRANCNFSM4XC7FZAA. You are receiving this because you commented.

Bruce R. Julian @.***

brucerjulian avatar Jul 19 '22 17:07 brucerjulian

I'm still having the same problem in with XQuartz 2.8.5 and OSX 12.4.

I had no problems a few versions of OSX back,

henrypfister avatar Apr 02 '23 16:04 henrypfister

Just found a workaround... it seems that we need to set the xterm after something else initializes. Add the following to the end of your .vimrc file:

function DelayedSetVariables(timer) set term=xterm endfunction let timer=timer_start(500,'DelayedSetVariables')

henrypfister avatar Apr 02 '23 17:04 henrypfister

Now I'm glad I hadn't updated my XQuartz that actually is working. I will have to update it eventually, so thank you for the workaround.

On Sun, Apr 2, 2023 at 1:00 PM Henry Pfister @.***> wrote:

Just found a workaround... it seems that we need to set the xterm after something else initializes. Add the following to the end of your .vimrc file:

function DelayedSetVariables(timer) set term=xterm endfunction let timer=timer_start(500,'DelayedSetVariables')

— Reply to this email directly, view it on GitHub https://github.com/XQuartz/XQuartz/issues/59#issuecomment-1493391380, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN24GJG2NEUCKVNUKE73DBLW7GWBZANCNFSM4XC7FZAA . You are receiving this because you commented.Message ID: @.***>

gkoenigsberger avatar Apr 03 '23 02:04 gkoenigsberger

@gkoenigsberger AIUI, this issue is not specific to any version of XQuartz. It's an issue observerd with the updated vim in newer versions of macOS.

jeremyhu avatar Apr 04 '23 01:04 jeremyhu