From e1bc9d0a44da9c27c5558767cdb75da1a3424a4b Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 5 Feb 2014 21:55:18 +0100 Subject: 32342: fix overstrike for vi mode and use varying vi commands at line start --- Src/Zle/zle_main.c | 16 ++++++++-------- Src/Zle/zle_vi.c | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index ed8577bcd..b0010fc33 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1198,14 +1198,6 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) statusline = NULL; selectkeymap("main", 1); initundo(); - /* - * If main is linked to the viins keymap, we need to register - * explicitly that we're now in vi insert mode as there's - * no user operation to indicate this. - */ - if (openkeymap("main") == openkeymap("viins")) - viinsert_init(); - selectlocalmap(NULL); fixsuffix(); if ((s = getlinknode(bufstack))) { setline(s, ZSL_TOEND); @@ -1222,6 +1214,14 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) stackhist = -1; } } + /* + * If main is linked to the viins keymap, we need to register + * explicitly that we're now in vi insert mode as there's + * no user operation to indicate this. + */ + if (openkeymap("main") == openkeymap("viins")) + viinsert_init(); + selectlocalmap(NULL); if (isset(PROMPTCR)) putc('\r', shout); if (tmout) diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 79b8cb958..994b44fe3 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -79,8 +79,9 @@ static void startvichange(int im) { if (im != -1) { - insmode = im; vichgflag = 1; + if (im > -1) + insmode = im; } if (inrepeat && im != -2) { zmod = lastmod; @@ -92,7 +93,8 @@ startvichange(int im) free(vichgbuf); vichgbuf = (char *)zalloc(vichgbufsz = 16); if (im == -2) { - vichgbuf[0] = 'a'; + vichgbuf[0] = + zlell ? (insmode ? (zlecs < zlell ? 'i' : 'a') : 'R') : 'o'; } else { vichgbuf[0] = lastchar; } -- cgit 1.4.1