1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 22:11:54 +02:00

32308: Improve initialising of vi change.

Better handling when entering viins on entry to editor.
Slightly changed since post to use vi command a.
This commit is contained in:
Peter Stephenson 2014-01-28 16:12:41 +00:00
parent a0c9da72f2
commit c56f5aed59
3 changed files with 33 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2014-01-28 Peter Stephenson <p.stephenson@samsung.com>
* 32308 (slightly modified to use "a" as the vi command at start
of line): Src/Zle/zle_main.c, Src/Zle/zle_vi.c: improve
initialising of vi mode change when entering viins at start of
editing.
2014-01-27 Peter Stephenson <p.stephenson@samsung.com>
* unposted: Src/zsh.mdd: update 31983 to suppress stdout from

View file

@ -1204,7 +1204,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish)
* no user operation to indicate this.
*/
if (openkeymap("main") == openkeymap("viins"))
viinsert(NULL);
viinsert_init();
selectlocalmap(NULL);
fixsuffix();
if ((s = getlinknode(bufstack))) {

View file

@ -67,6 +67,13 @@ int viinsbegin;
static struct modifier lastmod;
static int inrepeat, vichgrepeat;
/**
* im: >= 0: is an insertmode
* -1: skip setting insert mode
* -2: entering viins at start of editing from clean --- don't use
* inrepeat or lastchar, synthesise an i to enter insert mode.
*/
/**/
static void
startvichange(int im)
@ -75,7 +82,7 @@ startvichange(int im)
insmode = im;
vichgflag = 1;
}
if (inrepeat) {
if (inrepeat && im != -2) {
zmod = lastmod;
inrepeat = vichgflag = 0;
vichgrepeat = 1;
@ -84,7 +91,11 @@ startvichange(int im)
if (vichgbuf)
free(vichgbuf);
vichgbuf = (char *)zalloc(vichgbufsz = 16);
vichgbuf[0] = lastchar;
if (im == -2) {
vichgbuf[0] = 'a';
} else {
vichgbuf[0] = lastchar;
}
vichgbufptr = 1;
vichgrepeat = 0;
}
@ -303,6 +314,18 @@ viinsert(UNUSED(char **args))
return 0;
}
/*
* Go to vi insert mode when we first start the line editor.
* Iniialises some other stuff.
*/
/**/
void
viinsert_init(void)
{
startvitext(-2);
}
/**/
int
viinsertbol(UNUSED(char **args))