From 44c56f3af57d93d5d92ce18893cb020f8f36e2f3 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 29 Jun 2015 01:53:59 +0200 Subject: 35627: make reverse-menu-complete start with the last match in menu selection --- Src/Zle/compresult.c | 83 +++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 53 deletions(-) (limited to 'Src/Zle/compresult.c') diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 9f383f4b8..7fec7c804 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -1220,25 +1220,39 @@ do_menucmp(int lst) was_meta = 1; /* Otherwise go to the next match in the array... */ - do { - if (!*++(minfo.cur)) { - do { - if (!(minfo.group = (minfo.group)->next)) { - minfo.group = amatches; + while (zmult) { + do { + if (zmult > 0) { + if (!*++(minfo.cur)) { + do { + if (!(minfo.group = (minfo.group)->next)) { + minfo.group = amatches; #ifdef ZSH_HEAP_DEBUG - if (memory_validate(minfo.group->heap_id)) { - HEAP_ERROR(minfo.group->heap_id); - } + if (memory_validate(minfo.group->heap_id)) { + HEAP_ERROR(minfo.group->heap_id); + } #endif + } + } while (!(minfo.group)->mcount); + minfo.cur = minfo.group->matches; } - } while (!(minfo.group)->mcount); - minfo.cur = minfo.group->matches; - } - } while ((menuacc && - !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) || - ((*minfo.cur)->flags & CMF_DUMMY) || - (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) && - (!(*minfo.cur)->str || !*(*minfo.cur)->str))); + } else { + if (minfo.cur == (minfo.group)->matches) { + do { + if (!(minfo.group = (minfo.group)->prev)) + minfo.group = lmatches; + } while (!(minfo.group)->mcount); + minfo.cur = (minfo.group)->matches + (minfo.group)->mcount - 1; + } else + minfo.cur--; + } + } while ((menuacc && + !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) || + ((*minfo.cur)->flags & CMF_DUMMY) || + (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) && + (!(*minfo.cur)->str || !*(*minfo.cur)->str))); + zmult -= (0 < zmult) - (zmult < 0); + } /* ... and insert it into the command line. */ do_single(*minfo.cur); @@ -1246,43 +1260,6 @@ do_menucmp(int lst) unmetafy_line(); } -/**/ -int -reverse_menu(UNUSED(Hookdef dummy), UNUSED(void *dummy2)) -{ - int was_meta; - - if (minfo.cur == NULL) - return 1; - - do { - if (minfo.cur == (minfo.group)->matches) { - do { - if (!(minfo.group = (minfo.group)->prev)) - minfo.group = lmatches; - } while (!(minfo.group)->mcount); - minfo.cur = (minfo.group)->matches + (minfo.group)->mcount - 1; - } else - minfo.cur--; - } while ((menuacc && - !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) || - ((*minfo.cur)->flags & CMF_DUMMY) || - (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) && - (!(*minfo.cur)->str || !*(*minfo.cur)->str))); - /* May already be metafied if called from within a selection */ - if (zlemetaline == NULL) { - metafy_line(); - was_meta = 0; - } - else - was_meta = 1; - do_single(*(minfo.cur)); - if (!was_meta) - unmetafy_line(); - - return 0; -} - /* Accepts the current completion and starts a new arg, * * with the next completions. This gives you a way to * * accept several selections from the list of matches. */ -- cgit 1.4.1