]> granicus.if.org Git - vim/commitdiff
patch 8.2.3432: octave/Matlab filetype detection does not work properly v8.2.3432
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Sep 2021 15:03:08 +0000 (17:03 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Sep 2021 15:03:08 +0000 (17:03 +0200)
Problem:    Octave/Matlab filetype detection does not work properly.
Solution:   Update the patterns used for matching. (Doug Kearns)

runtime/autoload/dist/ft.vim
src/testdir/test_filetype.vim
src/version.c

index 48a9657cf5f7f75dc7a788192144847dd8f9d184..7484149a26d418d66af469ae3fd4e4f98c0a554b 100644 (file)
@@ -269,7 +269,8 @@ func dist#ft#FTm()
     return
   endif
 
-  let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>'
+  " excluding end(for|function|if|switch|while) common to Murphi
+  let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
 
   let n = 1
   let saw_comment = 0 " Whether we've seen a multiline comment leader.
@@ -285,8 +286,7 @@ func dist#ft#FTm()
       setf objc
       return
     endif
-    if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' ||
-         \ line =~ '^\s*unwind_protect\>' ||
+    if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
          \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
       setf octave
       return
index 94db223f9fcbb467bbe574b50a7c9220d2ba4b70..cd6e71d1b47758b07bb9e99b1a7bc5dd971a2e37 100644 (file)
@@ -893,16 +893,6 @@ func Test_m_file()
   call assert_equal('octave', &filetype)
   bwipe!
 
-  call writefile(['#{', 'Octave block comment',  '#}'], 'Xfile.m')
-  split Xfile.m
-  call assert_equal('octave', &filetype)
-  bwipe!
-
-  call writefile(['%{', 'Octave block comment', '%}'], 'Xfile.m')
-  split Xfile.m
-  call assert_equal('octave', &filetype)
-  bwipe!
-
   call writefile(['%!test "Octave test"'], 'Xfile.m')
   split Xfile.m
   call assert_equal('octave', &filetype)
@@ -913,7 +903,7 @@ func Test_m_file()
   call assert_equal('octave', &filetype)
   bwipe!
 
-  call writefile(['function test(); 42; endfunction'], 'Xfile.m')
+  call writefile(['try; 42; end_try_catch'], 'Xfile.m')
   split Xfile.m
   call assert_equal('octave', &filetype)
   bwipe!
@@ -925,6 +915,13 @@ func Test_m_file()
   call assert_equal('mma', &filetype)
   bwipe!
 
+  " MATLAB
+
+  call writefile(['% MATLAB line comment'], 'Xfile.m')
+  split Xfile.m
+  call assert_equal('matlab', &filetype)
+  bwipe!
+
   " Murphi
 
   call writefile(['-- Murphi comment'], 'Xfile.m')
index 053648a5586653251fa9a4b92a917423ff6e4e62..7d87105b6138249ef32b2cd58fc888e71e3998ea 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3432,
 /**/
     3431,
 /**/