aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorMichael Davis2024-03-17 13:42:16 +0000
committerBlaž Hrastnik2024-03-18 01:34:53 +0000
commit38af99f05f76dfcdb36e5b498a64b8c39b2fa27a (patch)
treee6097a1e0b9742b83e81cf6602a09a5e33658df9 /helix-core
parent476e6baf8f664bb08114aa5bf6bc839925d8d329 (diff)
Bump tree-sitter to 0.22.2
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 3b224e1b..0e891719 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -21,7 +21,7 @@ use std::{
collections::{HashMap, HashSet, VecDeque},
fmt::{self, Display},
hash::{Hash, Hasher},
- mem::{replace, transmute},
+ mem::replace,
path::{Path, PathBuf},
str::FromStr,
sync::Arc,
@@ -805,7 +805,7 @@ impl LanguageConfiguration {
if query_text.is_empty() {
return None;
}
- let lang = self.highlight_config.get()?.as_ref()?.language;
+ let lang = &self.highlight_config.get()?.as_ref()?.language;
Query::new(lang, &query_text)
.map_err(|e| {
log::error!(
@@ -1544,13 +1544,7 @@ impl PartialEq for LanguageLayer {
impl Hash for LanguageLayer {
fn hash<H: Hasher>(&self, state: &mut H) {
self.depth.hash(state);
- // The transmute is necessary here because tree_sitter::Language does not derive Hash at the moment.
- // However it does use #[repr] transparent so the transmute here is safe
- // as `Language` (which `Grammar` is an alias for) is just a newtype wrapper around a (thin) pointer.
- // This is also compatible with the PartialEq implementation of language
- // as that is just a pointer comparison.
- let language: *const () = unsafe { transmute(self.config.language) };
- language.hash(state);
+ self.config.language.hash(state);
self.ranges.hash(state);
}
}
@@ -1567,7 +1561,7 @@ impl LanguageLayer {
.map_err(|_| Error::InvalidRanges)?;
parser
- .set_language(self.config.language)
+ .set_language(&self.config.language)
.map_err(|_| Error::InvalidLanguage)?;
// unsafe { syntax.parser.set_cancellation_flag(cancellation_flag) };
@@ -1867,7 +1861,7 @@ impl HighlightConfiguration {
// Construct a single query by concatenating the three query strings, but record the
// range of pattern indices that belong to each individual string.
- let query = Query::new(language, &query_source)?;
+ let query = Query::new(&language, &query_source)?;
let mut highlights_pattern_index = 0;
for i in 0..(query.pattern_count()) {
let pattern_offset = query.start_byte_for_pattern(i);
@@ -1876,7 +1870,7 @@ impl HighlightConfiguration {
}
}
- let injections_query = Query::new(language, injection_query)?;
+ let injections_query = Query::new(&language, injection_query)?;
let combined_injections_patterns = (0..injections_query.pattern_count())
.filter(|&i| {
injections_query
@@ -2730,7 +2724,7 @@ mod test {
.unwrap();
let language = get_language("rust").unwrap();
- let query = Query::new(language, query_str).unwrap();
+ let query = Query::new(&language, query_str).unwrap();
let textobject = TextObjectQuery { query };
let mut cursor = QueryCursor::new();