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

    matlab-ts-mode--ei: add %-indent-mode=minimal and %-indent-mode=full
---
 doc/matlab-code-indent.org                         |  27 ++-
 matlab-ts-mode--ei.el                              | 217 +++++++++++++++------
 .../electric_indent_mode_minimal.m                 |  38 ++++
 .../electric_indent_mode_minimal_all.m             |   7 +
 .../electric_indent_mode_minimal_all_expected.m    |   7 +
 ...lectric_indent_mode_minimal_all_expected_msgs.m |   7 +
 .../electric_indent_mode_minimal_expected.m        |  38 ++++
 .../electric_indent_mode_minimal_expected_msgs.m   |  38 ++++
 .../electric_indent_mode_minimal.m                 |  38 ++++
 .../electric_indent_mode_minimal_all.m             |   7 +
 .../electric_indent_mode_minimal_all_expected.txt  |  17 ++
 .../electric_indent_mode_minimal_expected.txt      |  47 +++++
 12 files changed, 424 insertions(+), 64 deletions(-)

diff --git a/doc/matlab-code-indent.org b/doc/matlab-code-indent.org
index dc825b7cc8..8b0ed3d697 100644
--- a/doc/matlab-code-indent.org
+++ b/doc/matlab-code-indent.org
@@ -1,4 +1,4 @@
-# File: matlab-code-indent.org
+# File: doc/matlab-code-indent.org
 # Copyright (C) 2026 Free Software Foundation, Inc.
 
 #+startup: showall
@@ -44,6 +44,26 @@ When using matlab-ts-mode (and not matlab-mode) the MATLAB 
indent engine:
          reallyLongArg2);
    #+end_src
 
+2. How do I speed up a slow indent?
+
+   When there are a lot of language elements, for example a really big matrix 
with many columns and
+   rows, the indent can be very slow. You can wrap these in 
~%-indent-mode=minimal~ and
+   ~%-indent-mode=full~ comment directives. For example:
+
+   #+begin_src matlab
+     %-indent-mode=minimal
+     mat1 = [
+              % <lots of rows and columns>
+            ];
+     %-indent-mode=full
+   #+end_src
+
+   When indent-mode=minimal is active, only the indent-level whitespace on 
left  is modified when
+   the code is indented, which speeds up indent.
+
+   It should be possible to speedup matlab-ts-mode electric indent if anyone 
is interested in trying
+   to optimize it, let us know.
+
 * Indent Engine Design Considerations
 
 _Simplicity is good_
@@ -80,10 +100,13 @@ MATLAB language came up with a set of rules for MATLAB 
indent:
   structs, adds missing commas to matrices, etc.
 
 We choose to have no indent options and make sure the indents works well in 
all cases. This
-eliminates the need for comment directives like ~%#<indent off>~ and ~%<indent 
on>~. By having one
+eliminates the need for comment directives like ~%#<format-off>~ and 
~%<format-on>~. By having one
 indent standard, people reading code from different projects will see 
consistency. Consistency helps
 with understanding and communication.
 
+For performance considerations, we added ~%-indent-mode=minimal~ and 
~%-indent-mode=full~ comment
+directives.
+
 * MATLAB Indent Standard
 
 1. *Indent level of 4 spaces, no TAB characters, unicode, LF line-endings (no 
CRLF)*
diff --git a/matlab-ts-mode--ei.el b/matlab-ts-mode--ei.el
index 26926aa0f7..bc2d284bfd 100644
--- a/matlab-ts-mode--ei.el
+++ b/matlab-ts-mode--ei.el
@@ -1679,6 +1679,80 @@ We examine lines between START-LINENUM and END-LINENUM 
inclusive."
                                                         linenum)))
        (forward-line)))))
 
+(defun matlab-ts-mode--ei-get-disabled-regions ()
+  "Return regions disabled by %-indent-mode=minimal comments.
+Electric indent can be disabled then enabled using comments:
+  %-indent-mode=minimal
+    <code and comments>
+  %-indent-mode=full
+Code in the minimal region has the indent-level (spaces to the left)
+modified as required.  The elements within the lines are not
+modified.  For example,
+
+  %-indent-mode=minimal
+  if a >    1
+  disp( \"a > 1\")
+      end
+  %-indent-mode=full
+
+is indented to the following.  Notice that thew whitespace in line
+elements are not modified.
+
+  %-indent-mode=minimal
+  if a >    1
+      disp( \"a > 1\")
+  end
+  %-indent-mode=full
+
+If we remove the %-indent-mode=* comments, indent produces:
+
+  if a > 1
+      disp(\"a > 1\")
+  end
+
+Returns:
+    \\='((START-LINE1 . END-LINE1) (START-LINE2 . END-LINE2) ...))
+where START-LINE1 corresponds to the first %-indent-mode=minimal comment,
+END-LINE1 corresponds to the first %-indent-mode=full comment and so on."
+  (let (result
+        start-line)
+    (save-excursion
+      (save-restriction
+        (goto-char (point-min))
+        (while (re-search-forward (rx bol (0+ (or " " "\t"))
+                                      (group (or "%-indent-mode=minimal" 
"%-indent-mode=full"))
+                                      word-end)
+                                  nil t)
+          (let ((directive (match-string 1)))
+            (pcase directive
+              ("%-indent-mode=minimal"
+               (when (not start-line)
+                 (setq start-line (line-number-at-pos))))
+              ("%-indent-mode=full"
+               (when start-line
+                 (push `(,start-line . ,(line-number-at-pos)) result)
+                 (setq start-line nil)))
+              (_
+               (error "Assert: bad directive, %s" directive)))))
+        (when start-line
+          (push `(,start-line . ,(line-number-at-pos (point-max))) result))))
+    (reverse result)))
+
+(defun matlab-ts-mode--ei-in-disabled-region (&optional linenum 
disabled-regions )
+  "Is LINENUM in a DISABLED-REGIONS?
+LINENUM defaults to the current line.
+Returns the region (START-LINE . END-LINE) if disabled, else nil."
+  (when (not linenum)
+    (setq linenum (line-number-at-pos)))
+  (when (not disabled-regions)
+    (setq disabled-regions (matlab-ts-mode--ei-get-disabled-regions)))
+  (cl-loop for region in disabled-regions do
+           (let ((region-start (car region))
+                 (region-end (cdr region)))
+             (when (and (>= linenum region-start)
+                        (<= linenum region-end))
+               (cl-return region)))))
+
 (cl-defun matlab-ts-mode--ei-indent-elements-in-line (&optional 
is-indent-region start-pt-offset)
   "Indent current line by adjusting spacing around elements.
 
@@ -1694,6 +1768,9 @@ used to update the point location for
 When IS-INDENT-REGION is nil, we update the line and restore the point
 to it's logical location when the line is updated."
 
+  (when (matlab-ts-mode--ei-in-disabled-region)
+    (cl-return-from matlab-ts-mode--ei-indent-elements-in-line))
+
   ;; If line was indented (nth 0 ei-info) is not same as current line, then 
update the buffer
   (let* ((start-pair (when (or (not is-indent-region) start-pt-offset)
                        (matlab-ts-mode--ei-get-start-info)))
@@ -1773,12 +1850,9 @@ If INIT is non-nil, set to initial value, otherwise set 
to nil"
                 matlab-ts-mode--ei-errors-alist (when init 
(matlab-ts-mode--ei-get-errors-alist))
                 matlab-ts-mode--ei-orig-line-node-types-alist value)))
 
-(defun matlab-ts-mode--ei-indent-region (beg end)
-  "Indent BEG END region by adjusting spacing around elements.
-If BEG is not at start of line, it is moved to start of the line.
-If END is not at end of line, it is moved to end of the line.
-This expansion of the region is done to simplify electric indent."
-
+(cl-defun matlab-ts-mode--ei-indent-region-impl (new-content-buf beg end)
+  "Implementation for `matlab-ts-mode--ei-indent-region'.
+NEW-CONTENT-BUF is used to electric indent BEG to END region."
   ;; We need to run electric indent before treesit-indent-region. Consider
   ;;    l2 = @(x)((ischar(x) || isstring(x) || isnumeric(x)) && ...
   ;;                 ~strcmpi(x, 'fubar'));
@@ -1789,46 +1863,53 @@ This expansion of the region is done to simplify 
electric indent."
   ;; indented correctly.
   ;;    l2 = @(x) ((ischar(x) || isstring(x) || isnumeric(x)) && ...
   ;;              ~strcmpi(x, 'fubar'));
+
   (let* ((start-linenum (line-number-at-pos beg))
          (end-linenum (save-excursion (goto-char end)
                                       (- (line-number-at-pos) (if (= (point) 
(pos-bol)) 1 0))))
-         (max-end-linenum (= end-linenum (line-number-at-pos (point-max))))
-         (start-pt (point))
-         (start-pt-linenum (line-number-at-pos start-pt))
-         (start-pt-offset (- start-pt (save-excursion
-                                        (goto-char start-pt)
-                                        ;; offset from beginning of 
start-pt-linenum
-                                        (pos-bol))))
-         (new-content-buf (get-buffer-create
-                           (generate-new-buffer-name " 
*temp-matlab-indent-region*"))))
-
-    (matlab-ts-mode--ei-workaround-143 beg end) ;; may insert spaces on lines 
in BEG END region
-
-    (unwind-protect
-        (progn
-          (matlab-ts-mode--ei-set-alist-caches t)
-
-          (save-excursion
-            (save-restriction
-              (widen)
-              ;; Move END point to end of line.
-              ;; To do this, we use end-linenum, because workaround-143 could 
have moved END.
-              (goto-char (point-min))
-              (when (> end-linenum 1)
-                (forward-line (1- end-linenum)))
-              (let ((inhibit-field-text-motion t)) (end-of-line))
-              (setq end (point))
-              ;; Move BEG to beginning of line and leave point there.
-              (goto-char beg)
-              (forward-line 0)
-              (setq beg (point))
-
-              (let (region-updated
-                    (i-linenum start-linenum))
-
-                (while (<= i-linenum end-linenum)
+         (disabled-regions (matlab-ts-mode--ei-get-disabled-regions))
+         (start-disabled (matlab-ts-mode--ei-in-disabled-region start-linenum 
disabled-regions))
+         (end-disabled (matlab-ts-mode--ei-in-disabled-region end-linenum 
disabled-regions)))
+
+    (when (and start-disabled (equal start-disabled end-disabled))
+      (treesit-indent-region beg end)
+      (cl-return-from matlab-ts-mode--ei-indent-region-impl))
+
+    (let* ((max-end-linenum (= end-linenum (line-number-at-pos (point-max))))
+           (start-pt (point))
+           (start-pt-linenum (line-number-at-pos start-pt))
+           (start-pt-offset (- start-pt (save-excursion
+                                          (goto-char start-pt)
+                                          ;; offset from beginning of 
start-pt-linenum
+                                          (pos-bol)))))
+      (save-excursion
+        (save-restriction
+          (widen)
+          (matlab-ts-mode--ei-workaround-143 beg end) ;; may insert spaces on 
BEG to END lines
+
+          ;; Move END point to end of line.
+          ;; To do this, we use end-linenum, because workaround-143 could have 
moved END.
+          (goto-char (point-min))
+          (when (> end-linenum 1)
+            (forward-line (1- end-linenum)))
+          (let ((inhibit-field-text-motion t)) (end-of-line))
+          (setq end (point))
+          ;; Move BEG to beginning of line and leave point there.
+          (goto-char beg)
+          (forward-line 0)
+          (setq beg (point))
+
+          (let (region-updated
+                (i-linenum start-linenum))
+
+            (while (<= i-linenum end-linenum)
+              (let ((line-ending (if (or max-end-linenum (< i-linenum 
end-linenum)) "\n" "")))
+                (if (matlab-ts-mode--ei-in-disabled-region i-linenum 
disabled-regions)
+                    (let ((curr-line (buffer-substring (pos-bol) (pos-eol))))
+                      (with-current-buffer new-content-buf
+                        (insert curr-line line-ending)))
+                  ;; else: electric indent the line
                   (forward-line 0)
-
                   (let* ((tuple (matlab-ts-mode--ei-indent-elements-in-line
                                  'indent-region
                                  (when (= i-linenum start-pt-linenum)
@@ -1838,29 +1919,41 @@ This expansion of the region is done to simplify 
electric indent."
                          (line-updated (nth 1 tuple))
                          (new-start-pt-offset (nth 2 tuple)))
                     (with-current-buffer new-content-buf
-                      (insert new-line (if (or max-end-linenum (< i-linenum 
end-linenum)) "\n" "")))
+                      (insert new-line line-ending))
                     (when new-start-pt-offset
                       (setq start-pt-offset new-start-pt-offset))
                     (when line-updated
-                      (setq region-updated t)))
-
-                  (forward-line)
-                  (setq i-linenum (1+ i-linenum)))
-
-                (when region-updated
-                  (save-excursion
-                    (goto-char beg)
-                    (delete-region beg end)
-                    (insert (with-current-buffer new-content-buf 
(buffer-string)))
-                    (when matlab-ts-mode--indent-assert
-                      (matlab-ts-mode--ei-assert-line-nodes-match 
start-linenum end-linenum))
-                    ;; Restore END point accounting for electric indent changes
-                    (goto-char (point-min))
-                    (forward-line end-linenum)
-                    (setq end (point)))))))
-
-          (matlab-ts-mode--ei-move-to-loc start-pt-linenum start-pt-offset)
-          (treesit-indent-region beg end))
+                      (setq region-updated t)))))
+              (forward-line)
+              (setq i-linenum (1+ i-linenum)))
+
+            (when region-updated
+              (save-excursion
+                (goto-char beg)
+                (delete-region beg end)
+                (insert (with-current-buffer new-content-buf (buffer-string)))
+                (when matlab-ts-mode--indent-assert
+                  (matlab-ts-mode--ei-assert-line-nodes-match start-linenum 
end-linenum))
+                ;; Restore END point accounting for electric indent changes
+                (goto-char (point-min))
+                (forward-line end-linenum)
+                (setq end (point)))))))
+
+      (matlab-ts-mode--ei-move-to-loc start-pt-linenum start-pt-offset)
+      (treesit-indent-region beg end))))
+
+(defun matlab-ts-mode--ei-indent-region (beg end)
+  "Indent BEG END region by adjusting spacing around elements.
+If BEG is not at start of line, it is moved to start of the line.
+If END is not at end of line, it is moved to end of the line.
+This expansion of the region is done to simplify electric indent."
+
+  (let ((new-content-buf (get-buffer-create
+                          (generate-new-buffer-name " 
*temp-matlab-indent-region*"))))
+    (unwind-protect
+        (progn
+          (matlab-ts-mode--ei-set-alist-caches t)
+          (matlab-ts-mode--ei-indent-region-impl new-content-buf beg end))
 
       (matlab--eilb-kill)
       (matlab-ts-mode--ei-set-alist-caches nil)
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
new file mode 100644
index 0000000000..528fad5430
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
@@ -0,0 +1,38 @@
+% -*- matlab-ts -*-
+
+a = 1+2   * 3;
+
+disp(a   );
+
+%-indent-mode=minimal
+
+b = 1+2   * 3;
+
+disp( b  );
+
+
+%-indent-mode=full
+
+
+c = 1+2   * 3;
+
+disp( c  );
+
+
+% Following is misplaced (no prior minimal). This should casue an error.
+%-indent-mode=full
+
+d = 1+2   * 3;
+
+disp( d  );
+
+
+%-indent-mode=minimal
+
+
+% Following is misplaced (have prior minimal). This should casue an error.
+%-indent-mode=minimal
+
+e = 1+2   * 3;
+
+disp( e  );
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
new file mode 100644
index 0000000000..ee406468bb
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
@@ -0,0 +1,7 @@
+%-indent-mode=minimal -*- matlab-ts -*-
+
+a = 1+2 * 3;
+
+if a > 5
+         disp('a>5'   );
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.m
new file mode 100644
index 0000000000..3b2f63e1ef
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.m
@@ -0,0 +1,7 @@
+%-indent-mode=minimal -*- matlab-ts -*-
+
+a = 1+2 * 3;
+
+if a > 5
+    disp('a>5'   );
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected_msgs.m
new file mode 100644
index 0000000000..4632f6843b
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected_msgs.m
@@ -0,0 +1,7 @@
+%-indent-mode=minimal -*- matlab-ts -*- %  <{Matched rule: 
(matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+
+a = 1+2 * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+if a > 5 %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+    disp('a>5'   ); %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+end %  <{Matched rule: ((node-is 
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'") 
parent 0)}>
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.m
new file mode 100644
index 0000000000..e40548b6b4
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.m
@@ -0,0 +1,38 @@
+% -*- matlab-ts -*-
+
+a = 1 + 2 * 3;
+
+disp(a);
+
+%-indent-mode=minimal
+
+b = 1+2   * 3;
+
+disp( b  );
+
+
+%-indent-mode=full
+
+
+c = 1 + 2 * 3;
+
+disp(c);
+
+
+% Following is misplaced (no prior minimal). This should casue an error.
+%-indent-mode=full
+
+d = 1 + 2 * 3;
+
+disp(d);
+
+
+%-indent-mode=minimal
+
+
+% Following is misplaced (have prior minimal). This should casue an error.
+%-indent-mode=minimal
+
+e = 1+2   * 3;
+
+disp( e  );
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected_msgs.m
new file mode 100644
index 0000000000..92a1b2057b
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected_msgs.m
@@ -0,0 +1,38 @@
+% -*- matlab-ts -*- %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+a = 1 + 2 * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+disp(a); %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+%-indent-mode=minimal %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+b = 1+2   * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+disp( b  ); %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+
+%-indent-mode=full %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+
+c = 1 + 2 * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+disp(c); %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+
+% Following is misplaced (no prior minimal). This should casue an error. %  
<{Matched rule: (matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+%-indent-mode=full %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
+
+d = 1 + 2 * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+disp(d); %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+
+%-indent-mode=minimal %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+
+% Following is misplaced (have prior minimal). This should casue an error. %  
<{Matched rule: (matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+%-indent-mode=minimal %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
+
+e = 1+2   * 3; %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+disp( e  ); %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
diff --git 
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
new file mode 100644
index 0000000000..528fad5430
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal.m
@@ -0,0 +1,38 @@
+% -*- matlab-ts -*-
+
+a = 1+2   * 3;
+
+disp(a   );
+
+%-indent-mode=minimal
+
+b = 1+2   * 3;
+
+disp( b  );
+
+
+%-indent-mode=full
+
+
+c = 1+2   * 3;
+
+disp( c  );
+
+
+% Following is misplaced (no prior minimal). This should casue an error.
+%-indent-mode=full
+
+d = 1+2   * 3;
+
+disp( d  );
+
+
+%-indent-mode=minimal
+
+
+% Following is misplaced (have prior minimal). This should casue an error.
+%-indent-mode=minimal
+
+e = 1+2   * 3;
+
+disp( e  );
diff --git 
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
new file mode 100644
index 0000000000..ee406468bb
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all.m
@@ -0,0 +1,7 @@
+%-indent-mode=minimal -*- matlab-ts -*-
+
+a = 1+2 * 3;
+
+if a > 5
+         disp('a>5'   );
+end
diff --git 
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.txt
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.txt
new file mode 100644
index 0000000000..8f4be096c8
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_all_expected.txt
@@ -0,0 +1,17 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,94> (comment[1,40]@{%-indent-mode=minimal -*- matlab-ts -*-}@)
+ (assignment<42,53> left: (identifier[42,43]@{a}@) =[44,45]
+  right: 
+   (binary_operator<46,53> left: (number[46,47]@{1}@) +[47,48]
+    right: (binary_operator<48,53> left: (number[48,49]@{2}@) *[50,51] right: 
(number[52,53]@{3}@))))
+ ;[53,54] \n[54,56]
+ (if_statement<56,93> if[56,58]
+  condition: (comparison_operator<59,64> (identifier[59,60]@{a}@) >[61,62] 
(number[63,64]@{5}@))
+  (block<74,90>
+   (function_call<74,88> name: (identifier[74,78]@{disp}@) ([78,79]
+    (arguments<79,84>
+     argument: (string<79,84> '[79,80] (string_content[80,83]@{a>5}@) 
'[83,84]))
+    )[87,88])
+   ;[88,89] \n[89,90])
+  end[90,93])
+ \n[93,94])
diff --git 
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.txt
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.txt
new file mode 100644
index 0000000000..c353df01e0
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_mode_minimal_expected.txt
@@ -0,0 +1,47 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,428> (comment[1,20]@{% -*- matlab-ts -*-}@)
+ (assignment<22,35> left: (identifier[22,23]@{a}@) =[24,25]
+  right: 
+   (binary_operator<26,35> left: (number[26,27]@{1}@) +[27,28]
+    right: (binary_operator<28,35> left: (number[28,29]@{2}@) *[32,33] right: 
(number[34,35]@{3}@))))
+ ;[35,36]
+ (function_call<38,48> name: (identifier[38,42]@{disp}@) ([42,43]
+  (arguments<43,44> argument: (identifier[43,44]@{a}@))
+  )[47,48])
+ ;[48,49] (comment[51,72]@{%-indent-mode=minimal}@)
+ (assignment<74,87> left: (identifier[74,75]@{b}@) =[76,77]
+  right: 
+   (binary_operator<78,87> left: (number[78,79]@{1}@) +[79,80]
+    right: (binary_operator<80,87> left: (number[80,81]@{2}@) *[84,85] right: 
(number[86,87]@{3}@))))
+ ;[87,88]
+ (function_call<90,100> name: (identifier[90,94]@{disp}@) ([94,95]
+  (arguments<96,97> argument: (identifier[96,97]@{b}@))
+  )[99,100])
+ ;[100,101] (comment[104,122]@{%-indent-mode=full}@)
+ (assignment<125,138> left: (identifier[125,126]@{c}@) =[127,128]
+  right: 
+   (binary_operator<129,138> left: (number[129,130]@{1}@) +[130,131]
+    right: (binary_operator<131,138> left: (number[131,132]@{2}@) *[135,136] 
right: (number[137,138]@{3}@))))
+ ;[138,139]
+ (function_call<141,151> name: (identifier[141,145]@{disp}@) ([145,146]
+  (arguments<147,148> argument: (identifier[147,148]@{c}@))
+  )[150,151])
+ ;[151,152] (comment[155,246]@{% Following is misplaced (no prior minimal). 
This ...}@)
+ (assignment<248,261> left: (identifier[248,249]@{d}@) =[250,251]
+  right: 
+   (binary_operator<252,261> left: (number[252,253]@{1}@) +[253,254]
+    right: (binary_operator<254,261> left: (number[254,255]@{2}@) *[258,259] 
right: (number[260,261]@{3}@))))
+ ;[261,262]
+ (function_call<264,274> name: (identifier[264,268]@{disp}@) ([268,269]
+  (arguments<270,271> argument: (identifier[270,271]@{d}@))
+  )[273,274])
+ ;[274,275] (comment[278,299]@{%-indent-mode=minimal}@) (comment[302,398]@{% 
Following is misplaced (have prior minimal). Thi...}@)
+ (assignment<400,413> left: (identifier[400,401]@{e}@) =[402,403]
+  right: 
+   (binary_operator<404,413> left: (number[404,405]@{1}@) +[405,406]
+    right: (binary_operator<406,413> left: (number[406,407]@{2}@) *[410,411] 
right: (number[412,413]@{3}@))))
+ ;[413,414]
+ (function_call<416,426> name: (identifier[416,420]@{disp}@) ([420,421]
+  (arguments<422,423> argument: (identifier[422,423]@{e}@))
+  )[425,426])
+ ;[426,427] \n[427,428])

Reply via email to