branch: externals/matlab-mode
commit b56be645aae1b48fb87c5fe114fc2f14f66d76a9
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    matlab-ts-mode: don't indent assert when in error context
---
 matlab-ts-mode.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 77b10f5603..6ccf38835a 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -1523,14 +1523,18 @@ For optional _NODE, PARENT, and _BOL see 
`treesit-simple-indent-rules'."
 (defun matlab-ts-mode--indent-assert-no-rule (node parent bol &rest _)
   "Report no indent rule for NODE PARENT BOL."
   (when matlab-ts-mode--indent-assert
-    ;; Bad syntax errors shouldn't cause and assert because no rule matching 
means no indent will
-    ;; occur and that's okay.
-    (when (not (treesit-parent-until (or node parent) (rx bos "ERROR" eos)))
-      (error "Assert: no indent rule for: N:%S P:%S BOL:%S GP:%S NPS:%S BUF:%S"
-             node parent bol
-             (treesit-node-parent parent)
-             (treesit-node-prev-sibling node)
-             (buffer-name)))))
+    (let ((in-error (or (string= (treesit-node-type (or node parent)) "ERROR")
+                        (treesit-parent-until (or node parent) (rx bos "ERROR" 
eos)))))
+      ;; We shouldn't indent if we don't handle the particular error (no 
matched rule is okay
+      (when (not in-error)
+        (message "xxx1 %S" (or node parent))
+        (message "xxx2 %S" (treesit-parent-until (or node parent) (rx bos 
"ERROR" eos)))
+
+        (error "Assert: no indent rule for: N:%S P:%S BOL:%S GP:%S NPS:%S 
BUF:%S"
+               node parent bol
+               (treesit-node-parent parent)
+               (treesit-node-prev-sibling node)
+               (buffer-name))))))
 
 (defvar matlab-ts-mode--i-error-switch-matcher-pair)
 

Reply via email to