Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Two automargin fixes



This fixes the following two bugs which occur with terminals with
automatic margins.  In the following, suppose there is one command line
which wraps round to the next screen line.

Bug 1):  I reported this: if the last character on the first screen
line is a space, cutting and pasting doesn't work; the second line is
treated as a separate command.

Cause: As I'd hypothesised, refreshline() is too eager to save effort
by not printing the whole of the first line, instead printing up to
the last space and deleting the rest.

Fix: This simply requires an extra test before that code.  I can't see
this having any noticeable side effects.

Bug 2):  Inserting near the end of the first of the two lines causes
the second line to mess up: the second character is a duplicate of the
first, instead of what it should be.  (It gets more sporadic if the
second line is long, particularly if there's a third line, but
otherwise is reproducible.)

Cause:  The problem here was that the refresh code was using the first
character in the new line as the fix-up character for the beginning of
the line to trick automargin into working.  That's wrong in the case
of insertion, since the line initially looks like the old line, and
simply has an extra character inserted at the beginning.  With the
bug, the first character of the line was being replaced, then shifted
up.

Fix:  Use the first character of the old line, if there was one.  If
there wasn't, or it was different to the old one, we get a completely
new line anyway, so this should be fine too.

*** Src/zle_refresh.c.sp	Tue Nov 21 06:39:36 1995
--- Src/zle_refresh.c	Fri Dec  1 14:08:22 1995
***************
*** 463,472 ****
      }
  
  /* 2: see if we can clear to end-of-line, and if it's faster, work out where
!    to do it from - we can normally only do so if there's no right-prompt */
  
      col_cleareol = -1;
!     if (tccan(TCCLEAREOL) &&
  	(nllen == winw ||	/* new buffer goes to the end of the line */
  	put_rpmpt != oput_rpmpt)) {
  	for (i = nllen; i && nl[i - 1] == ' '; i--);
--- 463,474 ----
      }
  
  /* 2: see if we can clear to end-of-line, and if it's faster, work out where
!    to do it from - we can normally only do so if there's no right-prompt.
!    With automatic margins, we shouldn't do it if there is another line, in
!    case it messes up cut and paste. */
  
      col_cleareol = -1;
!     if (tccan(TCCLEAREOL) && (!hasam || ln == nlnct - 1) && 
  	(nllen == winw ||	/* new buffer goes to the end of the line */
  	put_rpmpt != oput_rpmpt)) {
  	for (i = nllen; i && nl[i - 1] == ' '; i--);
***************
*** 476,483 ****
  	    col_cleareol = i;
      }
  
! /* 3: set character for first column, in case automargin stuff needs doing */
!     am_char = *nl;
  
  /* 4: main display loop - write out the buffer using whatever tricks we can */
  
--- 478,486 ----
  	    col_cleareol = i;
      }
  
! /* 3: set character for first column, in case automargin stuff needs doing:
!    to begin with, this is the first char of the old screen line, if any. */
!     am_char = *ol ? *ol : *nl;
  
  /* 4: main display loop - write out the buffer using whatever tricks we can */
  

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author