summaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorPascal Kuthe2023-05-12 14:49:39 +0000
committerBlaž Hrastnik2023-05-18 06:23:37 +0000
commitb0705337bec836604bdb97689d0a44940c6bddae (patch)
tree4f7e3607cb891f290aae853f938d1db17a1e3c95 /helix-view/src
parent2f2306475cac7ee9385b816424137421c13bf4c2 (diff)
automatically disable TS when parsing takes longer than 500ms
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs11
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();