diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2015-11-06 00:50:18 +0100 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2015-11-10 03:13:31 +0100 |
commit | 3b12bb225adda2aac40a55f7009cae05311b2a43 (patch) | |
tree | e178e7bc5a5069007d431812cf08c7721c4c3762 | |
parent | dc65c8a8939b873d871f1a23a4b97382eca1df3c (diff) | |
download | rneovim-3b12bb225adda2aac40a55f7009cae05311b2a43.tar.gz rneovim-3b12bb225adda2aac40a55f7009cae05311b2a43.tar.bz2 rneovim-3b12bb225adda2aac40a55f7009cae05311b2a43.zip |
Add file selection prompt on ":oldfiles!"
:browse was removed for good, but some people miss ":browse oldfiles".
The same functionality is now provided by ":oldfiles!".
Helped-by: @Pyrohh
-rw-r--r-- | runtime/doc/starting.txt | 3 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 1 | ||||
-rw-r--r-- | src/nvim/eval.c | 23 |
3 files changed, 23 insertions, 4 deletions
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 41b4d22cf1..6e72f0cf6b 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1164,10 +1164,11 @@ running) you have additional options: :wv[iminfo][!] [file] Deprecated alias to |:wshada| command. *:o* *:ol* *:oldfiles* -:o[ldfiles] List the files that have marks stored in the ShaDa +:o[ldfiles][!] List the files that have marks stored in the ShaDa file. This list is read on startup and only changes afterwards with ":rshada!". Also see |v:oldfiles|. The number can be used with |c_#<|. + Use ! to get a file selection prompt. :bro[wse] o[ldfiles][!] List file names as with |:oldfiles|, and then prompt diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index b0b6d6df6e..b8de17738a 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -106,6 +106,7 @@ Additional differences: compatibility reasons. - |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old commands are still kept. +- |:oldfiles| supports !. - When writing (|:wshada| without bang or at exit) it merges much more data, and does this according to the timestamp. Vim merges only marks. |shada-merging| diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 045d513a4a..e1fa76c526 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21208,9 +21208,9 @@ void last_set_msg(scid_T scriptID) */ void ex_oldfiles(exarg_T *eap) { - list_T *l = vimvars[VV_OLDFILES].vv_list; + list_T *l = get_vim_var_list(VV_OLDFILES); listitem_T *li; - int nr = 0; + long nr = 0; if (l == NULL) msg((char_u *)_("No old files")); @@ -21218,7 +21218,7 @@ void ex_oldfiles(exarg_T *eap) msg_start(); msg_scroll = TRUE; for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) { - msg_outnum((long)++nr); + msg_outnum(++nr); MSG_PUTS(": "); msg_outtrans(get_tv_string(&li->li_tv)); msg_putchar('\n'); @@ -21228,6 +21228,23 @@ void ex_oldfiles(exarg_T *eap) /* Assume "got_int" was set to truncate the listing. */ got_int = FALSE; + // File selection prompt on ":oldfiles!" + if (eap->forceit) { + quit_more = false; + nr = prompt_for_number(false); + msg_starthere(); + if (nr > 0 && nr <= l->lv_len) { + char_u *p = list_find_str(l, nr); + if (p == NULL) { + return; + } + p = expand_env_save(p); + eap->arg = p; + eap->cmdidx = CMD_edit; + do_exedit(eap, NULL); + xfree(p); + } + } } } |