From 73d622e9c48519b4781120d154b868df882c0bbd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 25 Oct 2010 14:59:18 +0000 Subject: 28363: fix insert bug refreshing zle with wide characteter --- Src/Zle/zle_refresh.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 33a46a2f3..137065513 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -2000,7 +2000,7 @@ refreshline(int ln) newline: foobar / characters, then we have six matches */ if (tccan(TCDEL)) { int first = 1; - for (i = 1; ol[i].chr; i++) + for (i = 1; ol[i].chr; i++) { if (tcdelcost(i) < wpfxlen(ol + i, nl)) { /* * Some terminals will output the current @@ -2023,15 +2023,19 @@ refreshline(int ln) i = 0; break; } + } if (!i) continue; } - /* inserting characters - characters pushed off the right should be - annihilated, but we don't do this if we're on the last line lest - undesired scrolling occurs due to `illegal' characters on screen */ - - if (tccan(TCINS) && (vln != lines - 1)) { /* not on last line */ - for (i = 1; nl[i].chr; i++) + /* + * inserting characters - characters pushed off the right + * should be annihilated, but we don't do this if we're on the + * last line lest undesired scrolling occurs due to `illegal' + * characters on screen + */ + if (tccan(TCINS) && (vln != lines - 1)) { + /* not on last line */ + for (i = 1; nl[i].chr; i++) { if (tcinscost(i) < wpfxlen(ol, nl + i)) { tc_inschars(i); zwrite(nl, i); @@ -2044,19 +2048,37 @@ refreshline(int ln) #endif char_ins += i; ccs = (vcs += i); - /* if we've pushed off the right, truncate oldline */ - for (i = 0; ol[i].chr && i < winw - ccs; i++); + /* + * if we've pushed off the right, truncate + * oldline + */ + for (i = 0; ol[i].chr && i < winw - ccs; i++) + ; #ifdef MULTIBYTE_SUPPORT while (ol[i].chr == WEOF) i++; -#endif if (i >= winw - ccs) { + /* + * Yes, we're over the right. + * Make sure we truncate at the real + * character, not a WEOF added to + * make up the width. + */ + while (ol[i-1].chr == WEOF) + i--; ol[i] = zr_zr; ins_last = 1; } +#else + if (i >= winw - ccs) { + ol[i] = zr_zr; + ins_last = 1; + } +#endif i = 0; break; } + } if (!i) continue; } -- cgit 1.4.1