diff options
author | Pascal Kuthe | 2023-05-12 14:49:39 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-05-18 06:23:37 +0000 |
commit | b0705337bec836604bdb97689d0a44940c6bddae (patch) | |
tree | 4f7e3607cb891f290aae853f938d1db17a1e3c95 /helix-view | |
parent | 2f2306475cac7ee9385b816424137421c13bf4c2 (diff) |
automatically disable TS when parsing takes longer than 500ms
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 770341dc..eb376567 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -972,8 +972,7 @@ impl Document { ) { if let (Some(language_config), Some(loader)) = (language_config, loader) { if let Some(highlight_config) = language_config.highlight_config(&loader.scopes()) { - let syntax = Syntax::new(&self.text, highlight_config, loader); - self.syntax = Some(syntax); + self.syntax = Syntax::new(&self.text, highlight_config, loader); } self.language = Some(language_config); @@ -1113,9 +1112,11 @@ impl Document { // update tree-sitter syntax tree if let Some(syntax) = &mut self.syntax { // TODO: no unwrap - syntax - .update(&old_doc, &self.text, transaction.changes()) - .unwrap(); + let res = syntax.update(&old_doc, &self.text, transaction.changes()); + if res.is_err() { + log::error!("TS parser failed, disabeling TS for the current buffer: {res:?}"); + self.syntax = None; + } } let changes = transaction.changes(); |