Skip to content

Commit 114b279

Browse files
optimize
1 parent 8972606 commit 114b279

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

crates/pgt_hover/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn on_hover(params: OnHoverParams) -> Vec<String> {
109109
.find_schema(&schema_name)
110110
.map(Hoverable::from)
111111
.map(|s| vec![s])
112-
.unwrap_or(vec![]),
112+
.unwrap_or_default(),
113113

114114
_ => vec![],
115115
},

crates/pgt_treesitter/src/context/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,9 @@ impl<'a> TreesitterContext<'a> {
831831
NodeUnderCursor::TsNode(node) => {
832832
let mut cursor = node.walk();
833833
node.parent().is_some_and(|p| {
834-
for (i, child) in p.children(&mut cursor).enumerate() {
835-
if i + 1 == nth && child.id() == node.id() {
836-
return true;
837-
}
838-
}
839-
840-
false
834+
p.children(&mut cursor)
835+
.nth(nth - 1)
836+
.is_some_and(|n| n.id() == node.id())
841837
})
842838
}
843839
NodeUnderCursor::CustomNode { .. } => false,

0 commit comments

Comments
 (0)