diff options
author | Blaž Hrastnik | 2022-01-17 15:53:25 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-01-23 07:04:26 +0000 |
commit | 66a86123513ea5d6e9b7747eb3949a2695f23bee (patch) | |
tree | 9afbe1e7512946aa590b0da78a159b09a5e201d5 | |
parent | 2302869836eedf6bba718815fbff3a5fd7afee36 (diff) |
cleanup
-rw-r--r-- | helix-core/src/syntax.rs | 23 |
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, |