zsh-workers
 help / color / mirror / Atom feed
* Bug report: complist miscalculates width of display strings containing a slash (/)
@ 2021-03-26 22:49 Marlon Richert
  2021-04-04 16:08 ` Jun. T
  0 siblings, 1 reply; 2+ messages in thread
From: Marlon Richert @ 2021-03-26 22:49 UTC (permalink / raw)
  To: Zsh hackers list

The following test causes the command line to jump and the completion
menu to visually break when the terminal is 80 columns wide. Similar
effects can be achieved for other terminal sizes by adjusting the
length of the file names. In addition, thereafter, there are
additional redraw errors in the completion menu when changing the
selection. In particular, compare how the menu is redrawn when moving
the selection horizontally vs. vertically. All of this appears to
happen only for file completions of which the display string contains
a slash (/).

$ cd $(mktemp -d); ZDOTDIR=$PWD HOME=$PWD PS1='%# ' exec zsh -f
% zmodload zsh/complist
% autoload compinit; compinit
% mkdir {1..9}foobarba
% _tst() { local -a files=( ~/* ); local -a displ=( "${(@D)files}" );
compadd -d displ -P '~/' -fW ~/ - $files[@]:t }
% compdef _tst tst
% bindkey '^I' menu-select
% tst \t\t


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug report: complist miscalculates width of display strings containing a slash (/)
  2021-03-26 22:49 Bug report: complist miscalculates width of display strings containing a slash (/) Marlon Richert
@ 2021-04-04 16:08 ` Jun. T
  0 siblings, 0 replies; 2+ messages in thread
From: Jun. T @ 2021-04-04 16:08 UTC (permalink / raw)
  To: zsh-workers; +Cc: Marlon Richert


> 2021/03/27 7:49, Marlon Richert <marlon.richert@gmail.com> wrote:
> 
> The following test causes the command line to jump and the completion
> menu to visually break ...

Thank you for reporting, and sorry for not responding quickly.

It seems the problem occurs if both '-d disp' and '-f' are given to
compadd, and menu-select is called.
# It becomes more serious if width of the list of completions
# is equal (or close?) to the screen width due to the wrapping.

The following patch add an extra width 1 for the trailing file-type
indicator (/ for directory, etc.) when '-d disp' is given, just as for
the case without '-d disp' (line 2351, 15 lines below the patched line).



diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 30fc60b78..8b5955819 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1583,7 +1583,7 @@ calclist(int showall)
                             nlines += 1 + printfmt(m->disp, 0, 0, 0);
                             g->flags |= CGF_HASDL;
                         } else {
-                            l = ZMB_nicewidth(m->disp);
+                            l = ZMB_nicewidth(m->disp) + !!m->modec;
                             ndisp++;
                             if (l > glong)
                                 glong = l;





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-04 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 22:49 Bug report: complist miscalculates width of display strings containing a slash (/) Marlon Richert
2021-04-04 16:08 ` Jun. T

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git