mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1221: filtering does not work when listing marks
Problem: Filtering does not work when listing marks. Solution: Implement filtering marks. (Marcin Szamotulski, closes #3895)
This commit is contained in:
parent
0ee1bdff7d
commit
ad6dc49a75
@ -571,17 +571,19 @@ N *+X11* Unix only: can restore window title |X11|
|
|||||||
the output, not necessarily the whole line. Only some
|
the output, not necessarily the whole line. Only some
|
||||||
commands support filtering, try it out to check if it
|
commands support filtering, try it out to check if it
|
||||||
works. Some of the commands that support filtering:
|
works. Some of the commands that support filtering:
|
||||||
|:#| - filter whole line
|
|:#| - filter whole line
|
||||||
|:command| - filter by command name
|
|:clist| - filter by file name or module name
|
||||||
|:files| - filter by file name
|
|:command| - filter by command name
|
||||||
|:highlight| - filter by highlight group
|
|:files| - filter by file name
|
||||||
|:jumps| - filter by file name
|
|:highlight| - filter by highlight group
|
||||||
|:let| - filter by variable name
|
|:jumps| - filter by file name
|
||||||
|:list| - filter whole line
|
|:let| - filter by variable name
|
||||||
|:llist| - filter by file name or module name
|
|:list| - filter whole line
|
||||||
|:oldfiles| - filter by file name
|
|:llist| - filter by file name or module name
|
||||||
|:clist| - filter by file name or module name
|
|:marks| - filter by text in the current file,
|
||||||
|:set| - filter by variable name
|
or file name for other files
|
||||||
|
|:oldfiles| - filter by file name
|
||||||
|
|:set| - filter by variable name
|
||||||
|
|
||||||
Only normal messages are filtered, error messages are
|
Only normal messages are filtered, error messages are
|
||||||
not.
|
not.
|
||||||
|
40
src/mark.c
40
src/mark.c
@ -744,11 +744,12 @@ show_one_mark(
|
|||||||
int c,
|
int c,
|
||||||
char_u *arg,
|
char_u *arg,
|
||||||
pos_T *p,
|
pos_T *p,
|
||||||
char_u *name,
|
char_u *name_arg,
|
||||||
int current) /* in current file */
|
int current) /* in current file */
|
||||||
{
|
{
|
||||||
static int did_title = FALSE;
|
static int did_title = FALSE;
|
||||||
int mustfree = FALSE;
|
int mustfree = FALSE;
|
||||||
|
char_u *name = name_arg;
|
||||||
|
|
||||||
if (c == -1) /* finish up */
|
if (c == -1) /* finish up */
|
||||||
{
|
{
|
||||||
@ -762,35 +763,38 @@ show_one_mark(
|
|||||||
semsg(_("E283: No marks matching \"%s\""), arg);
|
semsg(_("E283: No marks matching \"%s\""), arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* don't output anything if 'q' typed at --more-- prompt */
|
// don't output anything if 'q' typed at --more-- prompt
|
||||||
else if (!got_int
|
else if (!got_int
|
||||||
&& (arg == NULL || vim_strchr(arg, c) != NULL)
|
&& (arg == NULL || vim_strchr(arg, c) != NULL)
|
||||||
&& p->lnum != 0)
|
&& p->lnum != 0)
|
||||||
{
|
{
|
||||||
if (!did_title)
|
if (name == NULL && current)
|
||||||
{
|
{
|
||||||
/* Highlight title */
|
name = mark_line(p, 15);
|
||||||
msg_puts_title(_("\nmark line col file/text"));
|
mustfree = TRUE;
|
||||||
did_title = TRUE;
|
|
||||||
}
|
}
|
||||||
msg_putchar('\n');
|
if (!message_filtered(name))
|
||||||
if (!got_int)
|
|
||||||
{
|
{
|
||||||
sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
|
if (!did_title)
|
||||||
msg_outtrans(IObuff);
|
|
||||||
if (name == NULL && current)
|
|
||||||
{
|
{
|
||||||
name = mark_line(p, 15);
|
// Highlight title
|
||||||
mustfree = TRUE;
|
msg_puts_title(_("\nmark line col file/text"));
|
||||||
|
did_title = TRUE;
|
||||||
}
|
}
|
||||||
if (name != NULL)
|
msg_putchar('\n');
|
||||||
|
if (!got_int)
|
||||||
{
|
{
|
||||||
msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
|
sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
|
||||||
if (mustfree)
|
msg_outtrans(IObuff);
|
||||||
vim_free(name);
|
if (name != NULL)
|
||||||
|
{
|
||||||
|
msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
out_flush(); // show one line at a time
|
||||||
}
|
}
|
||||||
out_flush(); /* show one line at a time */
|
if (mustfree)
|
||||||
|
vim_free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,22 @@ func Test_filter_commands()
|
|||||||
let res = split(execute("filter /\.c$/ jumps"), "\n")[1:]
|
let res = split(execute("filter /\.c$/ jumps"), "\n")[1:]
|
||||||
call assert_equal([" 2 1 0 file.c", ">"], res)
|
call assert_equal([" 2 1 0 file.c", ">"], res)
|
||||||
|
|
||||||
bwipe file.c
|
" Test filtering :marks command
|
||||||
bwipe file.h
|
b file.c
|
||||||
bwipe file.hs
|
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
|
endfunc
|
||||||
|
@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1221,
|
||||||
/**/
|
/**/
|
||||||
1220,
|
1220,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user