on master help sign in
Fix panic from indenting on tree with errors
3e84434Michael Davis
helix-core/src/indent.rs+6−2
@@ -511,8 +511,12 @@ fn extend_nodes<'a>(
511 *node = deepest_preceding;
511 *node = deepest_preceding;
512 break;
512 break;
513 }
513 }
514− // This parent always exists since node is an ancestor of deepest_preceding
514+ // If the tree contains a syntax error, `deepest_preceding` may not
515+ // have a parent despite being a descendant of `node`.
515− deepest_preceding = deepest_preceding.parent().unwrap();
516+ deepest_preceding = match deepest_preceding.parent() {
517+ Some(parent) => parent,
518+ None => return,
519+ }
516 }
520 }
517}
521}
518
522