Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump tree-sitter from 0.23.0 to 0.24.6 #183

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ ignore = "0.4.23"
itertools = "0.13.0"
log = "0.4.22"
pathdiff = "0.2.3"
streaming-iterator = "0.1.9"
tempfile = "3.13.0"
titlecase = "3.3.0"
tree-sitter = "0.23.0"
tree-sitter = "0.24.6"
tree-sitter-c = "0.23.4"
tree-sitter-c-sharp = "0.23.0"
tree-sitter-go = "0.23.4"
Expand Down
20 changes: 15 additions & 5 deletions src/scoping/langs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::borrow::Cow;

use log::{debug, info, trace};
use streaming_iterator::StreamingIterator; // TODO: remove once https://github.com/tree-sitter/tree-sitter/pull/4034 is released
use tree_sitter::{
Language as TSLanguage, Parser as TSParser, Query as TSQuery, QueryCursor as TSQueryCursor,
QueryError as TSQueryError,
Expand Down Expand Up @@ -173,12 +174,21 @@ pub trait LanguageScoper: Scoper + Find + Send + Sync {
trace!("Running query: {:?}", query);

let mut qc = TSQueryCursor::new();
let matches = qc.matches(query, root, input.as_bytes());
let mut matches = qc.matches(query, root, input.as_bytes());

let mut ranges: Ranges<usize> = matches
.flat_map(|query_match| query_match.captures)
.map(|capture| capture.node.byte_range())
.collect();
let mut ranges: Ranges<usize> = {
// The size hint is hard-coded to 0 currently so there's no effect; use it
// regardless as it might be useful in the future.
let mut ranges = Vec::with_capacity(matches.size_hint().1.unwrap_or_default());

while let Some(m) = matches.next() {
for capture in m.captures {
ranges.push(capture.node.byte_range());
}
}

ranges.into_iter().collect()
};

// ⚠️ tree-sitter queries with multiple captures will return them in some
// mixed order (not ordered, and not merged), but we later rely on cleanly
Expand Down
Loading