1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

39959: when repeating vi changes advance through the numbered killring registers

Also fix numeric arguments with vi-repeat-change: and argument passed
to the repeat replaces that previously saved with the change.
This commit is contained in:
Oliver Kiddle 2016-11-17 12:28:08 +01:00
parent 6d991ce177
commit 48bdcd7713
3 changed files with 45 additions and 9 deletions

View file

@ -1,5 +1,9 @@
2016-11-17 Oliver Kiddle <opk@zsh.org>
* 39959: Src/Zle/zle_vi.c, Test/X02zlevi.ztst: when repeating
vi changes advance through the numbered killring registers.
Also fix numeric arguments with vi-repeat-change.
* 39952: Src/Zle/zle_params.c, Doc/Zsh/zle.yo: add registers
special parameter to provide access to the vi register
buffers from a zle widget function

View file

@ -73,7 +73,13 @@ char *vichgbuf;
/**/
int viinsbegin;
/* value of zmod associated with vi change */
static struct modifier lastmod;
/*
* inrepeat: current widget is the vi change being repeated
* vichgrepeat: nested widget call within a repeat
*/
static int inrepeat, vichgrepeat;
/**
@ -81,6 +87,7 @@ static int inrepeat, vichgrepeat;
* -1: skip setting insert mode
* -2: entering viins at start of editing from clean --- don't use
* inrepeat or keybuf, synthesise an entry to insert mode.
* Note that zmult is updated so this should be called before zmult is used.
*/
/**/
@ -402,9 +409,10 @@ videlete(UNUSED(char **args))
int
videletechar(char **args)
{
int n = zmult;
int n;
startvichange(-1);
n = zmult;
/* handle negative argument */
if (n < 0) {
@ -451,9 +459,10 @@ vichange(UNUSED(char **args))
int
visubstitute(UNUSED(char **args))
{
int n = zmult;
int n;
startvichange(1);
n = zmult;
if (n < 0)
return 1;
/* it is an error to be on the end of line */
@ -547,9 +556,10 @@ int
viyankwholeline(UNUSED(char **args))
{
int bol = findbol(), oldcs = zlecs;
int n = zmult;
int n;
startvichange(-1);
n = zmult;
if (n < 1)
return 1;
while(n--) {
@ -591,8 +601,10 @@ int
vireplacechars(UNUSED(char **args))
{
ZLE_INT_T ch;
int n = zmult, fail = 0, newchars = 0;
int n, fail = 0, newchars = 0;
startvichange(1);
n = zmult;
if (n > 0) {
if (region_active) {
int a, b;
@ -629,7 +641,7 @@ vireplacechars(UNUSED(char **args))
n = pos - zlecs;
}
}
startvichange(1);
/* check argument range */
if (n < 1 || fail) {
if(vichgrepeat)
@ -802,7 +814,9 @@ virepeatchange(UNUSED(char **args))
lastmod.vibuf = zmod.vibuf;
lastmod.flags = (lastmod.flags & ~MOD_VIAPP) |
MOD_VIBUF | (zmod.flags & MOD_VIAPP);
}
} else if (lastmod.flags & MOD_VIBUF &&
lastmod.vibuf >= 27 && lastmod.vibuf <= 34)
lastmod.vibuf++; /* for "1 to "8 advance to next buffer */
/* repeat the command */
inrepeat = 1;
ungetbytes(vichgbuf, vichgbufptr);
@ -885,12 +899,13 @@ viunindent(UNUSED(char **args))
int
vibackwarddeletechar(char **args)
{
int n = zmult;
int n;
if (invicmdmode())
startvichange(-1);
/* handle negative argument */
n = zmult;
if (n < 0) {
int ret;
zmult = -n;
@ -930,10 +945,11 @@ int
vijoin(UNUSED(char **args))
{
int x, pos;
int n = zmult;
int n;
int visual = region_active;
startvichange(-1);
n = zmult;
if (n < 1)
return 1;
if (visual && zlecs > mark) {
@ -972,9 +988,10 @@ vijoin(UNUSED(char **args))
int
viswapcase(UNUSED(char **args))
{
int eol, n = zmult;
int eol, n;
startvichange(-1);
n = zmult;
if (n < 1)
return 1;
eol = findeol();

View file

@ -130,6 +130,16 @@
>long
>CURSOR: 0
zletest $'one two\e03rX$.'
0:repeat replace chars at the end of the line consumes the replace char
>BUFFER: XXX two
>CURSOR: 6
zletest $'one two three\e02rxw3.w.'
0:numeric argument to repeat replaces change count
>BUFFER: xxe xxx xxxee
>CURSOR: 10
zletest $'yankee doodle\ebhDyy0"1P'
0:paste register 1 to get last deletion
>BUFFER: doodleyankee
@ -176,6 +186,11 @@
0:retrieve unnamed register after appending
>BUFFER: second
>
>CURSOR: 0
zletest $'123456789\exxxxxxxxx"1P.........'
0:repeat advances to next killring register
>BUFFER: 9987654321
>CURSOR: 0
zletest $'Z\exayankee doodle\e"_db0"_yeP'