From 6785dcb5c920b6be812b4d1a70ce53ed47ff2f30 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 24 Feb 2000 14:44:28 +0000 Subject: zsh-workers/9865 --- Src/Zle/compresult.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Src/Zle/compresult.c') diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index e5d0617ef..64de5c744 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -610,6 +610,7 @@ do_ambiguous(void) do_ambig_menu(); } else if (ainfo) { int atend = (cs == we), la, eq, tcs; + VARARR(char, old, we - wb); minfo.cur = NULL; minfo.asked = 0; @@ -617,11 +618,25 @@ do_ambiguous(void) fixsuffix(); /* First remove the old string from the line. */ + tcs = cs; cs = wb; + memcpy(old, (char *) line + wb, we - wb); foredel(we - wb); /* Now get the unambiguous string and insert it into the line. */ cline_str(ainfo->line, 1, NULL); + + /* Sometimes the different match specs used may result in a cline + * that is shorter than the original string. If that happened, we + * re-insert the old string. Unless there were matches added with + * -U, that is. */ + if (lastend - wb < we - wb && !hasunmatched) { + cs = wb; + foredel(lastend - wb); + inststrlen(old, 0, we - wb); + lastend = we; + cs = tcs; + } if (eparq) { tcs = cs; cs = lastend; -- cgit 1.4.1