I am running R 3.2.2 under Arch Linux.
When I use R on the command line and resize the terminal, R does not take note of the changed terminal size. This is apparent when running a command whose output is long enough to wrap onto multiple lines (e.g. "letters"). It is, however, most inconvenient when entering a long command line. When I make the terminal smaller, for instance to share screen space with a plot window, then editing such a multi-line command becomes impossible, because Readline is confused about where the cursor is. Ctrl-A no longer visually takes the cursor to the start of the command, and when I enter some text after pressing Ctrl-A, the terminal becomes a mess of diagonal words. Since my plot commands are often very long (e.g. "plot(...); lines(...); abline(...); ...") and wrap onto multiple lines, and since plotting is what causes me to want to shrink my R terminal window temporarily, this bug is particularly inconvenient during the many occasions when I am trying to fiddle with a plot. I guess since it hasn't been fixed, other people must not be experiencing it with their setup or their way of using R - maybe they have bigger screens - but I noticed some related discussion on Stackoverflow:
I also saw this bug:
I, too, find that the COLUMNS environment variable is not updated when the window changes. But this is rather beside the point, because what I want is for R to e.g. trap SIGWINCH and update the width and alert Readline to the change as well. For what it's worth, other command-line programs like Octave and the Unix shells all have the desired behavior.
Thanks for reading...!
I was looking into working on this bug and came across
The above link documents (and fixes) the same problem in Python.
Apparently there was a change in signal handling behavior in Readline
6.3 due to a recognized need to conform with POSIX standards by not
calling certain functions from within signal handlers. The situation
seems to be well described at the above URL. Also, I believe that the
Python patch could be adapted fairly easily to apply to R.
One implication of the Python discussion is that R may have had the
correct SIGWINCH behavior prior to Readline 6.3. The same would apply
to proper SIGINT handling and Bug 16603. I did not start using R until
fairly recently, so I wouldn't know.
(In reply to Frederick Eaton from comment #1)
> One implication of the Python discussion is that R may have had the
> correct SIGWINCH behavior prior to Readline 6.3. The same would apply
I no longer have a system with a pre-6.3 readline and R, but from memory, this did used to work correctly in the past.
Created attachment 2071 [details]
fix for Readline 6.3 ignoring-SIGWINCH bug
Let me know what needs to be changed before this can be accepted. Thanks.
Frederick, thank you for the patch. I rebuilt R with it and I can confirm that it fixed the very annoying terminal width issue for me. If I can be of any assistance somehow in getting it accepted into R please let me know.
(In reply to Frederick Eaton from comment #3)
(In reply to Terran from comment #4)
> Frederick, thank you for the patch. I rebuilt R with it and I can confirm
> that it fixed the very annoying terminal width issue for me. If I can be of
> any assistance somehow in getting it accepted into R please let me know.
> (In reply to Frederick Eaton from comment #3)
For some reason we forgot to say here, but this bug was fixed ... indeed (partly) thanks to Frederick's patch for R version R 3.3.2 (and newer) quite a while ago.
So, Terran, did you observe the bug in R 3.3.2 ???
Ah; I just built 3.3.1 (the latest version available as source package for Debian stable), so the patch here applied cleanly for me and fixed the problem. I'll try to verify on a newer version that it's fixed as released and let you know here.