diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mark.c | 67 | ||||
-rw-r--r-- | src/nvim/testdir/test_filter_cmd.vim | 21 |
2 files changed, 53 insertions, 35 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index c87b612dbd..598fd79c0e 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -656,48 +656,51 @@ show_one_mark( int c, char_u *arg, pos_T *p, - char_u *name, - int current /* in current file */ + char_u *name_arg, + int current // in current file ) { - static int did_title = FALSE; - int mustfree = FALSE; - - if (c == -1) { /* finish up */ - if (did_title) - did_title = FALSE; - else { - if (arg == NULL) + static bool did_title = false; + bool mustfree = false; + char_u *name = name_arg; + + if (c == -1) { // finish up + if (did_title) { + did_title = false; + } else { + if (arg == NULL) { MSG(_("No marks set")); - else + } else { EMSG2(_("E283: No marks matching \"%s\""), arg); + } } - } - /* don't output anything if 'q' typed at --more-- prompt */ - else if (!got_int - && (arg == NULL || vim_strchr(arg, c) != NULL) - && p->lnum != 0) { - if (!did_title) { - /* Highlight title */ - MSG_PUTS_TITLE(_("\nmark line col file/text")); - did_title = TRUE; + } else if (!got_int + && (arg == NULL || vim_strchr(arg, c) != NULL) + && p->lnum != 0) { + // don't output anything if 'q' typed at --more-- prompt + if (name == NULL && current) { + name = mark_line(p, 15); + mustfree = true; } - msg_putchar('\n'); - if (!got_int) { - sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); - msg_outtrans(IObuff); - if (name == NULL && current) { - name = mark_line(p, 15); - mustfree = TRUE; + if (!message_filtered(name)) { + if (!did_title) { + // Highlight title + msg_puts_title(_("\nmark line col file/text")); + did_title = true; } - if (name != NULL) { - msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); - if (mustfree) { - xfree(name); + msg_putchar('\n'); + if (!got_int) { + snprintf((char *)IObuff, IOSIZE, " %c %6ld %4d ", c, p->lnum, p->col); + msg_outtrans(IObuff); + if (name != NULL) { + msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); } } + ui_flush(); // show one line at a time + } + if (mustfree) { + xfree(name); } - ui_flush(); /* show one line at a time */ } } diff --git a/src/nvim/testdir/test_filter_cmd.vim b/src/nvim/testdir/test_filter_cmd.vim index 6f40a902e1..0c45db049b 100644 --- a/src/nvim/testdir/test_filter_cmd.vim +++ b/src/nvim/testdir/test_filter_cmd.vim @@ -126,7 +126,22 @@ func Test_filter_commands() let res = split(execute("filter /\.c$/ jumps"), "\n")[1:] call assert_equal([" 2 1 0 file.c", ">"], res) - bwipe file.c - bwipe file.h - bwipe file.hs + " Test filtering :marks command + b file.c + mark A + b file.h + mark B + let res = split(execute("filter /\.c$/ marks"), "\n")[1:] + call assert_equal([" A 1 0 file.c"], res) + + call setline(1, ['one', 'two', 'three']) + 1mark a + 2mark b + 3mark c + let res = split(execute("filter /two/ marks abc"), "\n")[1:] + call assert_equal([" b 2 0 two"], res) + + bwipe! file.c + bwipe! file.h + bwipe! file.hs endfunc |