Python: Add suggestions from Copilot

This commit is contained in:
Taus
2025-09-03 11:55:49 +00:00
parent bda522052b
commit 13a93c7e32

View File

@@ -498,8 +498,11 @@ impl<'a> Iterator for TreeIterator<'a> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
if let Some(node) = self.nodes_to_visit.pop() { if let Some(node) = self.nodes_to_visit.pop() {
// Add all children to the queue for processing // Add all children to the queue for processing
self.nodes_to_visit let children: Vec<_> = (0..node.child_count())
.extend((0..node.child_count()).rev().filter_map(|i| node.child(i))); .rev()
.filter_map(|i| node.child(i))
.collect();
self.nodes_to_visit.extend(children);
Some(node) Some(node)
} else { } else {
None None
@@ -523,7 +526,7 @@ fn syntax_errors_from_tree<'a>(
.map(move |node| { .map(move |node| {
let start_pos = node.start_position(); let start_pos = node.start_position();
let end_pos = node.end_position(); let end_pos = node.end_position();
let text = &source[node.byte_range()]; let text = &source.get(node.byte_range()).unwrap_or("");
SyntaxError { SyntaxError {
start_pos, start_pos,
end_pos, end_pos,