mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-18 01:38:57 +00:00
Merge pull request #139 from cormacrelf/master
tree-sitter: ignore matches in inner scopes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user