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

    matlab-ts-mode--ei: argument constraints indent fix
---
 matlab-ts-mode.el                                        |  4 +++-
 .../electric_indent_arguments_constraints.m              | 16 ++++++++++++++++
 .../electric_indent_arguments_constraints_expected.m     | 16 ++++++++++++++++
 ...electric_indent_arguments_constraints_expected_msgs.m | 16 ++++++++++++++++
 .../electric_indent_m_matrix_trailing_comment_expected.m |  7 +++++++
 ...tric_indent_m_matrix_trailing_comment_expected_msgs.m |  7 +++++++
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index c9c872fb7a..053526d115 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -2660,7 +2660,9 @@ Example:
      ;;                 { ...
      ;;                   mustBeReal ...
      ;;                   ^                     <== TAB/RET to here
-     ((parent-is ,(rx bos "validation_functions" eos)) parent 2)
+     ((parent-is ,(rx bos "validation_functions" eos))
+      parent
+      ,(if matlab-ts-mode--electric-indent 1 2))
 
      ;; I-Rule: property after a property
      ;;         properties
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints.m
new file mode 100644
index 0000000000..99ae5608f5
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints.m
@@ -0,0 +1,16 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in 
error nodes
+
+function electric_indent_arguments_constraints(input1, params)
+    arguments
+        input11    (:,:)
+
+        params.foo1       = lines(1)
+        params.foobar     = 'auto'
+        params.fooBarZoo  = 'auto'
+        params.otherThing ...
+            {mustBeNumeric, mustBeReal, mustBeFinite, mustBeNonnegative, ...
+             mustBeNonsparse, mustBeLessThanOrEqual(params.otherThing, 1)} = 1
+    end
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected.m
new file mode 100644
index 0000000000..a314db2748
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected.m
@@ -0,0 +1,16 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in 
error nodes
+
+function electric_indent_arguments_constraints(input1, params)
+    arguments
+        input11 (:,:)
+
+        params.foo1       = lines(1)
+        params.foobar     = 'auto'
+        params.fooBarZoo  = 'auto'
+        params.otherThing ...
+            {mustBeNumeric, mustBeReal, mustBeFinite, mustBeNonnegative, ...
+             mustBeNonsparse, mustBeLessThanOrEqual(params.otherThing, 1)} = 1
+    end
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected_msgs.m
new file mode 100644
index 0000000000..48e02c32ac
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_arguments_constraints_expected_msgs.m
@@ -0,0 +1,16 @@
+% -*- matlab-ts -*- %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in 
error nodes %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+function electric_indent_arguments_constraints(input1, params) %  <{Matched 
rule: (matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+    arguments %  <{Matched rule: ((parent-is "\\`function_definition\\'") 
parent matlab-ts-mode--set-function-indent-level-for-gp)}>
+        input11 (:,:) %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+
+        params.foo1       = lines(1) %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+        params.foobar     = 'auto' %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+        params.fooBarZoo  = 'auto' %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+        params.otherThing ... %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+            {mustBeNumeric, mustBeReal, mustBeFinite, mustBeNonnegative, ... % 
 <{Matched rule: (matlab-ts-mode--i-cont-matcher parent 
matlab-ts-mode--i-cont-offset)}>
+             mustBeNonsparse, mustBeLessThanOrEqual(params.otherThing, 1)} = 1 
%  <{Matched rule: ((parent-is "\\`validation_functions\\'") parent 1)}>
+    end %  <{Matched rule: ((node-is 
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'") 
parent 0)}>
+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_m_matrix_trailing_comment_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_m_matrix_trailing_comment_expected.m
new file mode 100644
index 0000000000..fe7be56ddc
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_m_matrix_trailing_comment_expected.m
@@ -0,0 +1,7 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in 
error nodes
+
+NumberVar = [10; % comment 1
+              9; % comment2
+              7]; % foo
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_m_matrix_trailing_comment_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_m_matrix_trailing_comment_expected_msgs.m
new file mode 100644
index 0000000000..0e210f78aa
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_m_matrix_trailing_comment_expected_msgs.m
@@ -0,0 +1,7 @@
+% -*- matlab-ts -*- %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in 
error nodes %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+NumberVar = [10; % comment 1 %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+              9; % comment2 %  <{Matched rule: (matlab-ts-mode--i-row-matcher 
matlab-ts-mode--i-row-matcher-anchor matlab-ts-mode--i-row-matcher-offset)}>
+              7]; % foo %  <{Matched rule: (matlab-ts-mode--i-row-matcher 
matlab-ts-mode--i-row-matcher-anchor matlab-ts-mode--i-row-matcher-offset)}>

Reply via email to