Ignore unnamed nodes

This commit is contained in:
xenia 2023-11-12 17:26:53 +01:00
parent fc7288a27f
commit 1314dce07d
2 changed files with 4 additions and 0 deletions

View File

@ -52,6 +52,9 @@ impl Config {
impl FiletypeConfig { impl FiletypeConfig {
pub fn is_node_visible(&self, node: Node) -> bool { pub fn is_node_visible(&self, node: Node) -> bool {
let kind = node.kind(); let kind = node.kind();
if !node.is_named() {
return false;
}
match &self.whitelist { match &self.whitelist {
Some(whitelist) => whitelist.iter().any(|x| x == kind), Some(whitelist) => whitelist.iter().any(|x| x == kind),
None => match &self.blacklist { None => match &self.blacklist {

View File

@ -12,6 +12,7 @@ pub fn shrink_to_range<'a>(root_node: Node<'a>, range: &Range) -> Node<'a> {
for child in parent.children(&mut cursor) { for child in parent.children(&mut cursor) {
if child.range().start_byte <= range.start_byte if child.range().start_byte <= range.start_byte
&& range.end_byte <= child.range().end_byte && range.end_byte <= child.range().end_byte
&& child.is_named()
{ {
node = child; node = child;
continue 'outer; continue 'outer;