aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/indent.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index 1c813c9a..d6aa5edb 100644
--- a/helix-core/src/indent.rs
+++ b/helix-core/src/indent.rs
@@ -511,8 +511,12 @@ fn extend_nodes<'a>(
*node = deepest_preceding;
break;
}
- // This parent always exists since node is an ancestor of deepest_preceding
- deepest_preceding = deepest_preceding.parent().unwrap();
+ // If the tree contains a syntax error, `deepest_preceding` may not
+ // have a parent despite being a descendant of `node`.
+ deepest_preceding = match deepest_preceding.parent() {
+ Some(parent) => parent,
+ None => return,
+ }
}
}