zsh-workers
 help / color / mirror / code / Atom feed
* command line not refresh properly with wide chars when cursor would have been inside one
@ 2010-10-16 11:21 Mikael Magnusson
  2010-10-16 12:36 ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2010-10-16 11:21 UTC (permalink / raw)
  To: zsh workers

zsh -f
% echo ののの
% uuuuuu<up>
% echo の    [cursor here]

if you type one more (or less, or three or five more) letters, the
line refreshes properly, but when it would have ended up in the middle
of a wide char, the line gets cut off. This has bothered me for quite
some time but I've never been able to figure out the exact
circumstances before. Verified in latest cvs and 4.3.6 with -f.

-- 
Mikael Magnusson


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

* Re: command line not refresh properly with wide chars when cursor would have been inside one
  2010-10-16 11:21 command line not refresh properly with wide chars when cursor would have been inside one Mikael Magnusson
@ 2010-10-16 12:36 ` Mikael Magnusson
  2010-10-16 12:42   ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2010-10-16 12:36 UTC (permalink / raw)
  To: zsh workers

On 16 October 2010 13:21, Mikael Magnusson <mikachu@gmail.com> wrote:
> zsh -f
> % echo ののの
> % uuuuuu<up>
> % echo の    [cursor here]
>
> if you type one more (or less, or three or five more) letters, the
> line refreshes properly, but when it would have ended up in the middle
> of a wide char, the line gets cut off. This has bothered me for quite
> some time but I've never been able to figure out the exact
> circumstances before. Verified in latest cvs and 4.3.6 with -f.

Actually the problem is when the previous line ends in a wide char in
the new line, doesn't matter where the cursor is.

Hmm, it seems the problem is somewhere in refreshline (surprise,
right?). First all the characters of "echo の" are printed one by one,
but then ol is advanced past the end of the old string "uuuuuu" and
somehow after that are ののの which causes

/* skip past all matching characters */
for (; nl->chr && ZR_equal(*ol, *nl); nl++, ol++, ccs++)
    ;

to trigger, which is why the rest of the string isn't output. Why this
happens is a bit of a mystery to me still.

-- 
Mikael Magnusson


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

* Re: command line not refresh properly with wide chars when cursor would have been inside one
  2010-10-16 12:36 ` Mikael Magnusson
@ 2010-10-16 12:42   ` Mikael Magnusson
  2010-10-17 18:00     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2010-10-16 12:42 UTC (permalink / raw)
  To: zsh workers

On 16 October 2010 14:36, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 16 October 2010 13:21, Mikael Magnusson <mikachu@gmail.com> wrote:
>> zsh -f
>> % echo ののの
>> % uuuuuu<up>
>> % echo の    [cursor here]
>>
>> if you type one more (or less, or three or five more) letters, the
>> line refreshes properly, but when it would have ended up in the middle
>> of a wide char, the line gets cut off. This has bothered me for quite
>> some time but I've never been able to figure out the exact
>> circumstances before. Verified in latest cvs and 4.3.6 with -f.
>
> Actually the problem is when the previous line ends in a wide char in
> the new line, doesn't matter where the cursor is.
>
> Hmm, it seems the problem is somewhere in refreshline (surprise,
> right?). First all the characters of "echo の" are printed one by one,
> but then ol is advanced past the end of the old string "uuuuuu" and
> somehow after that are ののの which causes
>
> /* skip past all matching characters */
> for (; nl->chr && ZR_equal(*ol, *nl); nl++, ol++, ccs++)
>    ;
>
> to trigger, which is why the rest of the string isn't output. Why this
> happens is a bit of a mystery to me still.

This seems to fix the problem of skipping past the end of ol, but I'm
not sure if this is the exact spot that has a bug. I can't reproduce
my problem with this patch.

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index d36febb..e3307ef 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -2107,7 +2107,9 @@ refreshline(int ln)
 	     * We check for WEOF inside.
 	     */
 	    zputc(nl);
-	    nl++, ol++;
+	    nl++;
+	    if (ol->chr)
+	      ol++;
 	    ccs++, vcs++;
 #ifdef MULTIBYTE_SUPPORT
 	    /*

-- 
Mikael Magnusson


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

* Re: command line not refresh properly with wide chars when cursor would have been inside one
  2010-10-16 12:42   ` Mikael Magnusson
@ 2010-10-17 18:00     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2010-10-17 18:00 UTC (permalink / raw)
  To: zsh workers

On Sat, 16 Oct 2010 14:42:44 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> This seems to fix the problem of skipping past the end of ol, but I'm
> not sure if this is the exact spot that has a bug. I can't reproduce
> my problem with this patch.

Looks right to me, thanks.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

end of thread, other threads:[~2010-10-17 18:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-16 11:21 command line not refresh properly with wide chars when cursor would have been inside one Mikael Magnusson
2010-10-16 12:36 ` Mikael Magnusson
2010-10-16 12:42   ` Mikael Magnusson
2010-10-17 18:00     ` Peter Stephenson

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).