Merge pull request #139 from cormacrelf/master

tree-sitter: ignore matches in inner scopes
This commit is contained in:
Andy Massimino
2021-03-17 11:43:48 -04:00
committed by GitHub
2 changed files with 42 additions and 9 deletions

View File

@@ -248,13 +248,14 @@ function M.get_matching(delim, down, bufnr)
and (row >= info.search_range[1]
and row <= info.search_range[3]) then
local scope = M.containing_scope(node, bufnr, info.key)
local target_scope = M.containing_scope(node, bufnr, info.key)
if info.scope == target_scope then
local text = ts_utils.get_node_text(node, bufnr)[1]
table.insert(matches, {text, row + 1, col + 1})
local text = ts_utils.get_node_text(node, bufnr)[1]
table.insert(matches, {text, row + 1, col + 1})
if side == 'close' then
got_close = true
if side == 'close' then
got_close = true
end
end
end
end

View File

@@ -10,11 +10,16 @@ Execute (Helper):
endif
Given python (A python script):
def F(x):
def F(x, y):
if x == 1:
return 1
elif x == 2:
pass
if y == 5:
pass
elif y == 7:
return 9
else:
return x
else:
return 3
return 2
@@ -22,6 +27,8 @@ Given python (A python script):
Execute (Logs):
Log b:matchup_active_engines
# ----- outer if/elif/else -----
Before (Cursor):
normal! 2gg^
@@ -33,7 +40,7 @@ Then (Verify line):
Do (Move % twice):
%%
Then (Verify line):
Assert line('.') == (TSActive() ? 6 : 2)
Assert line('.') == (TSActive() ? 11 : 2)
Do (Move % 3 times):
%%%
@@ -44,3 +51,28 @@ Do (Move % 4 times):
%%%%
Then (Verify line):
Assert line('.') == (TSActive() ? 4 : 2)
# ----- inner if/elif/else -----
Before (Cursor):
normal! 5gg^
Do (Inner: Move %):
%
Then (Verify line):
Assert line('.') == (TSActive() ? 7 : 5)
Do (Inner: % 2 times):
%%
Then (Verify line):
Assert line('.') == (TSActive() ? 9 : 5)
Do (Inner: % 3 times):
%%%
Then (Verify line):
Assert line('.') == (TSActive() ? 5 : 5)
Do (Inner: % 4 times):
%%%%
Then (Verify line):
Assert line('.') == (TSActive() ? 7 : 5)