zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: complist with long display lines
Date: Thu, 10 Aug 2006 17:22:54 +0100	[thread overview]
Message-ID: <200608101622.k7AGMtNn027181@news01.csr.com> (raw)
In-Reply-To: <20060809230445.6eb66ce0.p.w.stephenson@ntlworld.com>

Peter Stephenson wrote:
> The same mistake seems to appear somewhere else, I think, and with some
> trepidation I've changed an occurrence in printfmt() in zle_tricky.c;
> you'll see that it does subtract the 1 further up in the bit where it's
> found a newline.

This appears to be wrong both here and the corresponding change in
complist.c, functions printfmt() and compprintfmt() respectively.  This
turned up when I was using the file-list zstyle with a description which
(including the file name at the end) just happened to hit the right hand
edge of the screen.  In this case, unlike the others, you get a new line at
the end of the display; I'm guessing this makes the difference.  (However,
obviously it isn't the calculation I'm modifying that produces the extra
newline, so I don't know where that comes from.)  The two changes affect
the non-complist and complist display of the same output.

This is different from the other cases because... er... oh look!  There's
Superman!  Over there!

Luckily, changing these doesn't undo the main point of the fix.  Phew.
I've subjected this to the combinations of tests I know about and they all
seem to work.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.88
diff -u -r1.88 complist.c
--- Src/Zle/complist.c	9 Aug 2006 22:08:38 -0000	1.88
+++ Src/Zle/complist.c	10 Aug 2006 16:15:47 -0000
@@ -1055,8 +1055,12 @@
     if (stat && n)
 	mfirstl = -1;
 
-    mlprinted = l + (cc ? ((cc-1) / columns) : 0);
-    return mlprinted;	    
+    /*
+     * *Not* subtracting 1 from cc at this point appears to be
+     * correct.  C.f. printfmt in zle_tricky.c.
+     */
+    mlprinted = l + (cc / columns);
+    return mlprinted;
 }
 
 /* This is like zputs(), but allows scrolling. */
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.71
diff -u -r1.71 zle_tricky.c
--- Src/Zle/zle_tricky.c	9 Aug 2006 22:08:39 -0000	1.71
+++ Src/Zle/zle_tricky.c	10 Aug 2006 16:15:49 -0000
@@ -2175,7 +2174,12 @@
 		putc(' ', shout);
 	}
     }
-    return l + ((cc-1) / columns);
+    /*
+     * Experiments suggest that at this point not subtracting 1 from
+     * cc is correct, i.e. if just misses wrapping we still add 1.
+     * (Why?)
+     */
+    return l + (cc / columns);
 }
 
 /* This is used to print expansions. */

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


      parent reply	other threads:[~2006-08-10 16:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-07 15:40 Peter Stephenson
2006-08-07 17:19 ` Bart Schaefer
2006-08-07 21:56   ` DervishD
2006-08-09 22:04   ` Peter Stephenson
2006-08-10  8:01     ` Bart Schaefer
2006-08-10  9:27       ` Peter Stephenson
2006-08-10 16:22     ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200608101622.k7AGMtNn027181@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).