on master help sign in
cleanup
commit66a86123513ea5d6e9b7747eb3949a2695f23bee authorBlaž Hrastnik <blaz@mxxn.io> dateTue 18 Jan 2022, 00:53 (5 years ago) parent2302869
1 file changed+6−17
helix-core/src/syntax.rs+6−17
helix-core/src/syntax.rs+6−17
@@ -209,12 +209,9 @@ impl LanguageConfiguration {
209209 &highlights_query,
210210 &injections_query,
211211 &locals_query,
212− );
212+ )
213+ .unwrap(); // TODO: avoid panic
213214
214− let config = match config {
215− Ok(config) => config,
216− Err(err) => panic!("{}", err),
217− }; // TODO: avoid panic
218215 config.configure(scopes);
219216 Some(Arc::new(config))
220217 }
@@ -392,12 +389,6 @@ pub struct TsParser {
392389 cursors: Vec<QueryCursor>,
393390}
394391
395−impl fmt::Debug for TsParser {
396− fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
397− f.debug_struct("TsParser").finish()
398− }
399−}
400−
401392// could also just use a pool, or a single instance?
402393thread_local! {
403394 pub static PARSER: RefCell<TsParser> = RefCell::new(TsParser {
@@ -433,14 +424,12 @@ impl Syntax {
433424 }],
434425 };
435426
436− // track markers of injections
437427 // track scope_descriptor: a Vec of scopes for item in tree
438428
439429 let mut layers = HopSlotMap::default();
440430 let root = layers.insert(root_layer);
441431
442432 let mut syntax = Self {
443− // grammar,
444433 root,
445434 layers,
446435 loader,
@@ -724,15 +713,15 @@ impl Syntax {
724713 .layers
725714 .iter()
726715 .filter_map(|(_, layer)| {
716+ // TODO: if range doesn't overlap layer range, skip it
717+ // we can calculate intersection and use it later for set_byte_range
718+
727719 // Reuse a cursor from the pool if available.
728720 let mut cursor = PARSER.with(|ts_parser| {
729721 let highlighter = &mut ts_parser.borrow_mut();
730722 highlighter.cursors.pop().unwrap_or_else(QueryCursor::new)
731723 });
732724
733− // TODO: if range doesn't overlap layer range, skip it
734− // we can calculate intersection and use it later for set_byte_range
735−
736725 // The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
737726 // prevents them from being moved. But both of these values are really just
738727 // pointers, so it's actually ok to move them.
@@ -783,7 +772,7 @@ impl Syntax {
783772
784773 let mut result = HighlightIter {
785774 source,
786− byte_offset: range.map_or(0, |r| r.start), // TODO: simplify
775+ byte_offset: range.map_or(0, |r| r.start),
787776 cancellation_flag,
788777 iter_count: 0,
789778 layers,