From 1314dce07d2a5c164ab4a89284d4c71bb7cd4917 Mon Sep 17 00:00:00 2001 From: xenia Date: Sun, 12 Nov 2023 17:26:53 +0100 Subject: [PATCH] Ignore unnamed nodes --- src/config.rs | 3 +++ src/tree.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/config.rs b/src/config.rs index 357a3ae..1ef53a2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,6 +52,9 @@ impl Config { impl FiletypeConfig { pub fn is_node_visible(&self, node: Node) -> bool { let kind = node.kind(); + if !node.is_named() { + return false; + } match &self.whitelist { Some(whitelist) => whitelist.iter().any(|x| x == kind), None => match &self.blacklist { diff --git a/src/tree.rs b/src/tree.rs index 92a3e2d..e7ffbc7 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -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) { if child.range().start_byte <= range.start_byte && range.end_byte <= child.range().end_byte + && child.is_named() { node = child; continue 'outer;