|
|
@ -21,7 +21,7 @@ use std::{
|
|
|
|
borrow::Cow,
|
|
|
|
borrow::Cow,
|
|
|
|
cell::RefCell,
|
|
|
|
cell::RefCell,
|
|
|
|
collections::{HashMap, HashSet, VecDeque},
|
|
|
|
collections::{HashMap, HashSet, VecDeque},
|
|
|
|
fmt::{self, Display},
|
|
|
|
fmt::{self, Display, Write},
|
|
|
|
hash::{Hash, Hasher},
|
|
|
|
hash::{Hash, Hasher},
|
|
|
|
mem::replace,
|
|
|
|
mem::replace,
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
path::{Path, PathBuf},
|
|
|
@ -729,8 +729,11 @@ pub fn read_query(language: &str, filename: &str) -> String {
|
|
|
|
.replace_all(&query, |captures: ®ex::Captures| {
|
|
|
|
.replace_all(&query, |captures: ®ex::Captures| {
|
|
|
|
captures[1]
|
|
|
|
captures[1]
|
|
|
|
.split(',')
|
|
|
|
.split(',')
|
|
|
|
.map(|language| format!("\n{}\n", read_query(language, filename)))
|
|
|
|
.fold(String::new(), |mut output, language| {
|
|
|
|
.collect::<String>()
|
|
|
|
// `write!` to a String cannot fail.
|
|
|
|
|
|
|
|
write!(output, "\n{}\n", read_query(language, filename)).unwrap();
|
|
|
|
|
|
|
|
output
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.to_string()
|
|
|
|
.to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1245,7 +1248,7 @@ impl Syntax {
|
|
|
|
PARSER.with(|ts_parser| {
|
|
|
|
PARSER.with(|ts_parser| {
|
|
|
|
let ts_parser = &mut ts_parser.borrow_mut();
|
|
|
|
let ts_parser = &mut ts_parser.borrow_mut();
|
|
|
|
ts_parser.parser.set_timeout_micros(1000 * 500); // half a second is pretty generours
|
|
|
|
ts_parser.parser.set_timeout_micros(1000 * 500); // half a second is pretty generours
|
|
|
|
let mut cursor = ts_parser.cursors.pop().unwrap_or_else(QueryCursor::new);
|
|
|
|
let mut cursor = ts_parser.cursors.pop().unwrap_or_default();
|
|
|
|
// TODO: might need to set cursor range
|
|
|
|
// TODO: might need to set cursor range
|
|
|
|
cursor.set_byte_range(0..usize::MAX);
|
|
|
|
cursor.set_byte_range(0..usize::MAX);
|
|
|
|
cursor.set_match_limit(TREE_SITTER_MATCH_LIMIT);
|
|
|
|
cursor.set_match_limit(TREE_SITTER_MATCH_LIMIT);
|
|
|
@ -1419,7 +1422,7 @@ impl Syntax {
|
|
|
|
// Reuse a cursor from the pool if available.
|
|
|
|
// Reuse a cursor from the pool if available.
|
|
|
|
let mut cursor = PARSER.with(|ts_parser| {
|
|
|
|
let mut cursor = PARSER.with(|ts_parser| {
|
|
|
|
let highlighter = &mut ts_parser.borrow_mut();
|
|
|
|
let highlighter = &mut ts_parser.borrow_mut();
|
|
|
|
highlighter.cursors.pop().unwrap_or_else(QueryCursor::new)
|
|
|
|
highlighter.cursors.pop().unwrap_or_default()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
|
|
|
|
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
|
|
|
|