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

    matlab-ts-mode: update to latest matlab tree-sitter, handle end index
    
    All tests now pass with the latest
     
https://github.com/acristoffers/tree-sitter-matlab/tree/55c67e978552ebc3110bf83af7a2d3bfa62f3834
    created on Aug-8-2025.
    
    Added face for end keyword used as an number index, e.g.
    
      v=1:10
      w=(2:end)
---
 matlab-ts-mode.el                                           | 10 ++++++++--
 .../test-matlab-ts-mode-font-lock-files/font_lock_numbers.m | 13 +++++++++++++
 .../font_lock_numbers_expected.txt                          | 13 +++++++++++++
 tests/test-matlab-ts-mode-font-lock.el                      |  1 +
 4 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 6efa02139a..ef62618e56 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -112,6 +112,11 @@ Guidelines:
   '((t :inherit font-lock-constant-face))
   "*Face used for numbers.")
 
+(defface matlab-ts-mode-end-number-face
+  '((t :inherit matlab-ts-mode-number-face
+       :slant italic))
+  "*Face used for \"end\" when used as an array or cell dimension number 
index.")
+
 (defcustom matlab-ts-mode-font-lock-level 3
   "*Level of font lock for MATLAB code.
 The \"Standard\" level plus either MLint flycheck or the MATLAB Language
@@ -790,7 +795,8 @@ than the FILED-EXPRESSION-NODE start-point and end-point."
    ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers.m
    :language 'matlab
    :feature 'number
-   '((number) @matlab-ts-mode-number-face)
+   '(((number) @matlab-ts-mode-number-face)
+     ((end_keyword) @matlab-ts-mode-end-number-face))
 
    ;; F-Rule: Brackets
    ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_brackets.m
@@ -3199,7 +3205,7 @@ is t, add the following to an Init File (e.g. 
`user-init-file' or
     ;;      - Test LSP vs MLint
     ;;      - Rename menu item "Check MLint Setup" to "Check setup" and have it
     ;;        look at both LSP and MLint. Place menu item at bottom.
-    ;;    
+    ;;
     ;; TODO check abbrev mode - think this is setup by prog-mode, also see 
matlab-mode
     ;;
     ;; TODO org mode matlab-ts-mode blocks testing
diff --git a/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers.m 
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers.m
index 85c3655043..164ef186ec 100644
--- a/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers.m
+++ b/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers.m
@@ -6,3 +6,16 @@ b = 3;
 
 c = 3e10;
 
+d = [1:10;
+     2:2:20];
+
+e = d(2:end, end:end);
+
+if e == 20
+    disp('correct')
+else
+    disp('bug!')
+end
+
+
+
diff --git 
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers_expected.txt 
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers_expected.txt
index 696c9a9148..f092a511ae 100644
--- a/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers_expected.txt
+++ b/tests/test-matlab-ts-mode-font-lock-files/font_lock_numbers_expected.txt
@@ -6,3 +6,16 @@ v o nD
 
 v o nnnnD
 
+v o bnDnnD
+     nDnDnnbD
+
+v o dbnDNNND NNNDNNNbD
+
+kk d oo nn
+    BBBBbSsssssssSb
+kkkk
+    BBBBbSssssSb
+kkk
+
+
+
diff --git a/tests/test-matlab-ts-mode-font-lock.el 
b/tests/test-matlab-ts-mode-font-lock.el
index c8949ddc00..0fe9a99b8f 100644
--- a/tests/test-matlab-ts-mode-font-lock.el
+++ b/tests/test-matlab-ts-mode-font-lock.el
@@ -78,6 +78,7 @@ after validating it, rename it to
                          ("k" . font-lock-keyword-face)
                          ("M" . matlab-ts-mode-comment-to-do-marker-face)
                          ("n" . matlab-ts-mode-number-face)
+                         ("N" . matlab-ts-mode-end-number-face)
                          ("o" . matlab-ts-mode-operator-face)
                          ("p" . matlab-ts-mode-pragma-face)
                          ("P" . matlab-ts-mode-property-face)

Reply via email to