Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion runtime/doc/starting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1609,13 +1609,17 @@ most of the information will be restored).
{not in Vi}

*:ol* *:oldfiles*
:ol[dfiles] List the files that have marks stored in the viminfo
:ol[dfiles] [/{pat}/] List the files that have marks stored in the viminfo
file. This list is read on startup and only changes
afterwards with ":rviminfo!". Also see |v:oldfiles|.
The number can be used with |c_#<|.
If {pat} is given only files matching the pattern will
be included. The pattern must be enclosed in / or any
non-ID character, like for |:vimgrep|.
{not in Vi, only when compiled with the |+eval|
feature}


:bro[wse] ol[dfiles][!]
List file names as with |:oldfiles|, and then prompt
for a number. When the number is valid that file from
Expand Down
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,7 @@ test_arglist \
test_menu \
test_messages \
test_netbeans \
test_oldfiles \
test_options \
test_packadd \
test_partial \
Expand Down
25 changes: 24 additions & 1 deletion src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -8938,22 +8938,45 @@ ex_oldfiles(exarg_T *eap UNUSED)
list_T *l = vimvars[VV_OLDFILES].vv_list;
listitem_T *li;
int nr = 0;
char_u *reg_pat;
char_u *buf;
regmatch_T regmatch;

if (l == NULL)
msg((char_u *)_("No old files"));
else
{
msg_start();
msg_putchar('\n');
msg_scroll = TRUE;
if (*eap->arg != NUL) {
if (skip_vimgrep_pat(eap->arg, &reg_pat, NULL) == NULL) {
EMSG(_(e_invalpat));
return;
}
regmatch.regprog = vim_regcomp(reg_pat, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL) {
return;
}
}
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
{
buf = get_tv_string(&li->li_tv);
if (*eap->arg != NUL && reg_pat != NULL && *reg_pat != NUL) {
if (!vim_regexec(&regmatch, buf, (colnr_T)0)) {
++nr;
continue;
}
}
msg_outnum((long)++nr);
MSG_PUTS(": ");
msg_outtrans(get_tv_string(&li->li_tv));
msg_outtrans(buf);
msg_putchar('\n');
out_flush(); /* output one line at a time */
ui_breakcheck();
}
if (*eap->arg != NUL)
vim_regfree(regmatch.regprog);
/* Assume "got_int" was set to truncate the listing. */
got_int = FALSE;

Expand Down
2 changes: 1 addition & 1 deletion src/ex_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ EX(CMD_open, "open", ex_open,
RANGE|BANG|EXTRA,
ADDR_LINES),
EX(CMD_oldfiles, "oldfiles", ex_oldfiles,
BANG|TRLBAR|SBOXOK|CMDWIN,
BANG|TRLBAR|NOTADR|EXTRA|SBOXOK|CMDWIN,
ADDR_LINES),
EX(CMD_omap, "omap", ex_map,
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,
Expand Down
10 changes: 6 additions & 4 deletions src/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -7775,10 +7775,12 @@ do_highlight(
i = (color < 7 || color == 8);
/* Set the 'background' option if the value is
* wrong. */
if (i != (*p_bg == 'd'))
set_option_value((char_u *)"bg", 0L,
i ? (char_u *)"dark"
: (char_u *)"light", 0);
/*
* if (i != (*p_bg == 'd'))
* set_option_value((char_u *)"bg", 0L,
* i ? (char_u *)"dark"
* : (char_u *)"light", 0);
*/
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/testdir/test_oldfiles.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"Tests for :olffiles vim: setf=vim :

func Test_oldfiles()
let ol = ['a.vim', 'b.vim', 'c.txt', 'd.txt']
call extend(v:oldfiles, ol)
redir @q
ol
redir END
call assert_equal(split(@q, "\n"), ['1: a.vim', '2: b.vim', '3: c.txt', '4: d.txt'])
redir @q
ol /\.txt$/
redir END
call assert_equal(split(@q, "\n"), ['3: c.txt', '4: d.txt'])
redir @q
ol /b[^/]*$/
redir END
call assert_equal(split(@q, "\n"), ['2: b.vim'])
endfunc