nvim-treesitter-context
nvim-treesitter-context copied to clipboard
dropping duplicates in display window
As of now its pretty impossible to drop duplicates based on node id.
The reason being is if we match the following:
patterns = {
"else_clause",
"if_statement",
}
in typescript an else if
statement has both of those in a parent child relationship, so you will get 2 copies of the else if ...
A simple fix would be to not append to the list if the previous item is exactly the same.
Thoughts?
Sorry, I don't 100% understand the issue. Can you provide an example?
The problem here is that an else if clause is parsed as an else clause, that happens to contain an if statement.
For example this code:
if (false) {
} else if (true) {
}
is parsed as:
if_statement [0, 0] - [4, 1]
condition: parenthesized_expression [0, 3] - [0, 10]
false [0, 4] - [0, 9]
consequence: statement_block [0, 11] - [2, 1]
alternative: else_clause [2, 2] - [4, 1]
if_statement [2, 7] - [4, 1]
condition: parenthesized_expression [2, 10] - [2, 16]
true [2, 11] - [2, 15]
consequence: statement_block [2, 17] - [4, 1]
This shouldn't be an issue anymore, since a context line is only added once even if there are multiple matches in it. At least I can't reproduce it.