1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-20 06:56:05 +02:00

33823: overwrite mode shouldn't replace newlines

This commit is contained in:
Oliver Kiddle 2014-11-30 23:37:01 +01:00
parent 62aa039317
commit d2505f108e
3 changed files with 26 additions and 11 deletions

View File

@ -1,5 +1,8 @@
2014-11-30 Oliver Kiddle <opk@zsh.org>
* 33823: Src/Zle/zle_misc.c, Test/X02zlevi.ztst: overwrite mode
shouldn't replace newlines
* 33820: configure.ac, Src/hist.c: detect support for realpath()
with a NULL argument and fixes to the use of it

View File

@ -47,13 +47,13 @@ doinsert(ZLE_STRING_T zstr, int len)
iremovesuffix(c1, 0);
invalidatelist();
if (insmode)
/* In overwrite mode, don't replace newlines. */
if (insmode || zleline[zlecs] == ZWC('\n'))
spaceinline(m * len);
else
#ifdef MULTIBYTE_SUPPORT
{
int pos = zlecs, diff, i;
#ifdef MULTIBYTE_SUPPORT
/*
* Calculate the number of character positions we are
* going to be using. The algorithm is that
@ -68,15 +68,18 @@ doinsert(ZLE_STRING_T zstr, int len)
* useful there anyway and this doesn't cause any
* particular harm.
*/
for (i = 0, count = 0; i < len; i++) {
for (i = 0, count = 0; i < len * m; i++) {
if (!IS_COMBINING(zstr[i]))
count++;
}
#else
count = len * m;
#endif
/*
* Ensure we replace a complete combining character
* for each character we overwrite.
* Ensure we replace a complete combining characterfor each
* character we overwrite. Switch to inserting at first newline.
*/
for (i = count; pos < zlell && i--; ) {
for (i = count; pos < zlell && zleline[pos] != ZWC('\n') && i--; ) {
INCPOS(pos);
}
/*
@ -96,10 +99,6 @@ doinsert(ZLE_STRING_T zstr, int len)
shiftchars(zlecs, diff);
}
}
#else
if (zlecs + m * len > zlell)
spaceinline(zlecs + m * len - zlell);
#endif
while (m--)
for (s = zstr, count = len; count; s++, count--)
zleline[zlecs++] = *s;

View File

@ -43,6 +43,19 @@
>
>CURSOR: 2
zletest $'\eOword\eO\eraok\ejrxj.rae'
0:replace character when at end of buffer or newline
>BUFFER: ok
>wxrd
>e
>CURSOR: 9
zletest $'two\eOone\ehRreplace'
0:replace acts like insert at newline
>BUFFER: oreplace
>two
>CURSOR: 8
zletest $' four\eO\C-v\tthree\eO two\eOone\e3J'
0:join lines with line count
>BUFFER: one two three