From: Daniel Carl Date: Sat, 1 Mar 2014 22:09:36 +0000 (+0100) Subject: Allow to complete multiple tags for :bma command. X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=accc644b1a83785e5679ec73839a678c5ef89d4e;p=vimb.git Allow to complete multiple tags for :bma command. The bookmark adding allowed to complete the given tag out of the known tags in the bookmark file. But this could only be done for the first tag. This patch allows to complete multiple tags like ':bma tag1 tag2 ta'. --- diff --git a/src/ex.c b/src/ex.c index 89775c7..7d8b22a 100644 --- a/src/ex.c +++ b/src/ex.c @@ -944,27 +944,47 @@ static gboolean complete(short direction) before_cmdname = in; if (parse_command_name(&in, arg) && *in == ' ') { - OVERWRITE_NSTRING(excomp.prefix, input, in - input + 1); + const char *token; + /* get only the last word of input string for the completion for + * bookmark tag completion */ + if (arg->code == EX_BMA) { + /* find the end of the input and search for the next + * whitespace toward the beginning */ + token = strrchr(in, '\0'); + while (token >= in && *token != ' ') { + token--; + } + } else { + /* use all input except ot the command itself for the + * completion */ + token = in; + } + + /* save the string prefix that will not be part of completion like + * the ':open ' if ':open something' is completed. this means that + * the complation will only the none prefix part of the input */ + OVERWRITE_NSTRING(excomp.prefix, input, token - input + 1); - skip_whitespace(&in); + /* the token points to a space, skip this */ + skip_whitespace(&token); switch (arg->code) { case EX_OPEN: case EX_TABOPEN: - if (*in == '!') { - found = bookmark_fill_completion(store, in + 1); + if (*token == '!') { + found = bookmark_fill_completion(store, token + 1); } else { - found = history_fill_completion(store, HISTORY_URL, in); + found = history_fill_completion(store, HISTORY_URL, token); } break; case EX_SET: sort = true; - found = setting_fill_completion(store, in); + found = setting_fill_completion(store, token); break; case EX_BMA: sort = true; - found = bookmark_fill_tag_completion(store, in); + found = bookmark_fill_tag_completion(store, token); break; default: