Skip to content

Commit 13a93c7

Browse files
committed
Python: Add suggestions from Copilot
1 parent bda5220 commit 13a93c7

File tree

1 file changed

+6
-3
lines changed
  • python/extractor/tsg-python/src

1 file changed

+6
-3
lines changed

python/extractor/tsg-python/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,11 @@ impl<'a> Iterator for TreeIterator<'a> {
498498
fn next(&mut self) -> Option<Self::Item> {
499499
if let Some(node) = self.nodes_to_visit.pop() {
500500
// Add all children to the queue for processing
501-
self.nodes_to_visit
502-
.extend((0..node.child_count()).rev().filter_map(|i| node.child(i)));
501+
let children: Vec<_> = (0..node.child_count())
502+
.rev()
503+
.filter_map(|i| node.child(i))
504+
.collect();
505+
self.nodes_to_visit.extend(children);
503506
Some(node)
504507
} else {
505508
None
@@ -523,7 +526,7 @@ fn syntax_errors_from_tree<'a>(
523526
.map(move |node| {
524527
let start_pos = node.start_position();
525528
let end_pos = node.end_position();
526-
let text = &source[node.byte_range()];
529+
let text = &source.get(node.byte_range()).unwrap_or("");
527530
SyntaxError {
528531
start_pos,
529532
end_pos,

0 commit comments

Comments
 (0)