aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-01-17 15:53:25 +0000
committerBlaž Hrastnik2022-01-23 07:04:26 +0000
commit66a86123513ea5d6e9b7747eb3949a2695f23bee (patch)
tree9afbe1e7512946aa590b0da78a159b09a5e201d5 /helix-core
parent2302869836eedf6bba718815fbff3a5fd7afee36 (diff)
cleanup
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs23
1 files changed, 6 insertions, 17 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 3deee459..4a64aacc 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -209,12 +209,9 @@ impl LanguageConfiguration {
&highlights_query,
&injections_query,
&locals_query,
- );
+ )
+ .unwrap(); // TODO: avoid panic
- let config = match config {
- Ok(config) => config,
- Err(err) => panic!("{}", err),
- }; // TODO: avoid panic
config.configure(scopes);
Some(Arc::new(config))
}
@@ -392,12 +389,6 @@ pub struct TsParser {
cursors: Vec<QueryCursor>,
}
-impl fmt::Debug for TsParser {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.debug_struct("TsParser").finish()
- }
-}
-
// could also just use a pool, or a single instance?
thread_local! {
pub static PARSER: RefCell<TsParser> = RefCell::new(TsParser {
@@ -433,14 +424,12 @@ impl Syntax {
}],
};
- // track markers of injections
// track scope_descriptor: a Vec of scopes for item in tree
let mut layers = HopSlotMap::default();
let root = layers.insert(root_layer);
let mut syntax = Self {
- // grammar,
root,
layers,
loader,
@@ -724,15 +713,15 @@ impl Syntax {
.layers
.iter()
.filter_map(|(_, layer)| {
+ // TODO: if range doesn't overlap layer range, skip it
+ // we can calculate intersection and use it later for set_byte_range
+
// Reuse a cursor from the pool if available.
let mut cursor = PARSER.with(|ts_parser| {
let highlighter = &mut ts_parser.borrow_mut();
highlighter.cursors.pop().unwrap_or_else(QueryCursor::new)
});
- // TODO: if range doesn't overlap layer range, skip it
- // we can calculate intersection and use it later for set_byte_range
-
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
// prevents them from being moved. But both of these values are really just
// pointers, so it's actually ok to move them.
@@ -783,7 +772,7 @@ impl Syntax {
let mut result = HighlightIter {
source,
- byte_offset: range.map_or(0, |r| r.start), // TODO: simplify
+ byte_offset: range.map_or(0, |r| r.start),
cancellation_flag,
iter_count: 0,
layers,