aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-07-01 14:02:48 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-07-15 23:07:28 -0400
commit263d62f628ee611c883b216bd9098484293d46a0 (patch)
tree76b0f65213dcc9901a4250035f682640c35f635f /src
parent990f99658bb060ac2ac4e1cff2966eab1e96f9d9 (diff)
downloadrneovim-263d62f628ee611c883b216bd9098484293d46a0.tar.gz
rneovim-263d62f628ee611c883b216bd9098484293d46a0.tar.bz2
rneovim-263d62f628ee611c883b216bd9098484293d46a0.zip
vim-patch:8.1.0495: :filter only supports some commands
Problem: :filter only supports some commands. Solution: Add :filter support for more commands. (Marcin Szamotulski, closes vim/vim#2856) https://github.com/vim/vim/commit/f86db78fed78541cefdb706e4779ce5ae9ca7820
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/mark.c5
-rw-r--r--src/nvim/option.c5
-rw-r--r--src/nvim/syntax.c6
-rw-r--r--src/nvim/testdir/test_filter_cmd.vim40
5 files changed, 66 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 6a5149614b..0e60f7a35a 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1782,6 +1782,15 @@ static void list_hashtable_vars(hashtab_T *ht, const char *prefix, int empty,
if (!HASHITEM_EMPTY(hi)) {
todo--;
di = TV_DICT_HI2DI(hi);
+ char buf[IOSIZE];
+
+ // apply :filter /pat/ to variable name
+ xstrlcpy(buf, prefix, IOSIZE - 1);
+ xstrlcat(buf, (char *)di->di_key, IOSIZE);
+ if (message_filtered((char_u *)buf)) {
+ continue;
+ }
+
if (empty || di->di_tv.v_type != VAR_STRING
|| di->di_tv.vval.v_string != NULL) {
list_one_var(di, prefix, first);
@@ -20851,6 +20860,9 @@ void ex_function(exarg_T *eap)
if (!HASHITEM_EMPTY(hi)) {
--todo;
fp = HI2UF(hi);
+ if (message_filtered(fp->uf_name)) {
+ continue;
+ }
if (!func_name_refcount(fp->uf_name)) {
list_func_head(fp, false);
}
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 2f2f2a7d74..c87b612dbd 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -786,8 +786,11 @@ void ex_jumps(exarg_T *eap)
for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) {
if (curwin->w_jumplist[i].fmark.mark.lnum != 0) {
name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
- if (name == NULL) /* file name not available */
+
+ // apply :filter /pat/ or file name not available
+ if (name == NULL || message_filtered(name)) {
continue;
+ }
msg_putchar('\n');
if (got_int) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index d6dbb14653..8483c02bbe 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -5047,6 +5047,11 @@ showoptions(
// collect the items in items[]
item_count = 0;
for (p = &options[0]; p->fullname != NULL; p++) {
+ // apply :filter /pat/
+ if (message_filtered((char_u *)p->fullname)) {
+ continue;
+ }
+
varp = NULL;
if (opt_flags != 0) {
if (p->indir != PV_NONE) {
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 3066ffbb0c..470c77eb93 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -350,7 +350,7 @@ static reg_extmatch_T *next_match_extmatch = NULL;
/*
* A state stack is an array of integers or stateitem_T, stored in a
- * garray_T. A state stack is invalid if it's itemsize entry is zero.
+ * garray_T. A state stack is invalid if its itemsize entry is zero.
*/
#define INVALID_STATE(ssp) ((ssp)->ga_itemsize == 0)
#define VALID_STATE(ssp) ((ssp)->ga_itemsize != 0)
@@ -7028,6 +7028,10 @@ static void highlight_list_one(const int id)
struct hl_group *const sgp = &HL_TABLE()[id - 1]; // index is ID minus one
bool didh = false;
+ if (message_filtered(sgp->sg_name)) {
+ return;
+ }
+
didh = highlight_list_arg(id, didh, LIST_ATTR,
sgp->sg_cterm, NULL, "cterm");
didh = highlight_list_arg(id, didh, LIST_INT,
diff --git a/src/nvim/testdir/test_filter_cmd.vim b/src/nvim/testdir/test_filter_cmd.vim
index 86347ab77f..3d802f9530 100644
--- a/src/nvim/testdir/test_filter_cmd.vim
+++ b/src/nvim/testdir/test_filter_cmd.vim
@@ -87,3 +87,43 @@ func Test_filter_cmd_with_filter()
call assert_equal('a|b', out)
set shelltemp&
endfunction
+
+func Test_filter_commands()
+ let g:test_filter_a = 1
+ let b:test_filter_b = 2
+ let test_filter_c = 3
+
+ " Test filtering :let command
+ let res = split(execute("filter /^test_filter/ let"), "\n")
+ call assert_equal(["test_filter_a #1"], res)
+
+ let res = split(execute("filter /\\v^(b:)?test_filter/ let"), "\n")
+ call assert_equal(["test_filter_a #1", "b:test_filter_b #2"], res)
+
+ unlet g:test_filter_a
+ unlet b:test_filter_b
+ unlet test_filter_c
+
+ " Test filtering :set command
+ let res = join(split(execute("filter /^help/ set"), "\n")[1:], " ")
+ call assert_match('^\s*helplang=\w*$', res)
+
+ " Test filtering :llist command
+ call setloclist(0, [{"filename": "/path/vim.c"}, {"filename": "/path/vim.h"}, {"module": "Main.Test"}])
+ let res = split(execute("filter /\\.c$/ llist"), "\n")
+ call assert_equal([" 1 /path/vim.c: "], res)
+
+ let res = split(execute("filter /\\.Test$/ llist"), "\n")
+ call assert_equal([" 3 Main.Test: "], res)
+
+ " Test filtering :jump command
+ e file.c
+ e file.h
+ e file.hs
+ 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
+endfunc