Skip to content

Commit ca0627d

Browse files
committed
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Problem: Octave/Matlab filetype detection does not work properly. Solution: Update the patterns used for matching. (Doug Kearns)
1 parent dfe04db commit ca0627d

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

runtime/autoload/dist/ft.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ func dist#ft#FTm()
269269
return
270270
endif
271271

272-
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>'
272+
" excluding end(for|function|if|switch|while) common to Murphi
273+
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
273274

274275
let n = 1
275276
let saw_comment = 0 " Whether we've seen a multiline comment leader.
@@ -285,8 +286,7 @@ func dist#ft#FTm()
285286
setf objc
286287
return
287288
endif
288-
if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' ||
289-
\ line =~ '^\s*unwind_protect\>' ||
289+
if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
290290
\ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
291291
setf octave
292292
return

src/testdir/test_filetype.vim

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -893,16 +893,6 @@ func Test_m_file()
893893
call assert_equal('octave', &filetype)
894894
bwipe!
895895

896-
call writefile(['#{', 'Octave block comment', '#}'], 'Xfile.m')
897-
split Xfile.m
898-
call assert_equal('octave', &filetype)
899-
bwipe!
900-
901-
call writefile(['%{', 'Octave block comment', '%}'], 'Xfile.m')
902-
split Xfile.m
903-
call assert_equal('octave', &filetype)
904-
bwipe!
905-
906896
call writefile(['%!test "Octave test"'], 'Xfile.m')
907897
split Xfile.m
908898
call assert_equal('octave', &filetype)
@@ -913,7 +903,7 @@ func Test_m_file()
913903
call assert_equal('octave', &filetype)
914904
bwipe!
915905

916-
call writefile(['function test(); 42; endfunction'], 'Xfile.m')
906+
call writefile(['try; 42; end_try_catch'], 'Xfile.m')
917907
split Xfile.m
918908
call assert_equal('octave', &filetype)
919909
bwipe!
@@ -925,6 +915,13 @@ func Test_m_file()
925915
call assert_equal('mma', &filetype)
926916
bwipe!
927917

918+
" MATLAB
919+
920+
call writefile(['% MATLAB line comment'], 'Xfile.m')
921+
split Xfile.m
922+
call assert_equal('matlab', &filetype)
923+
bwipe!
924+
928925
" Murphi
929926

930927
call writefile(['-- Murphi comment'], 'Xfile.m')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3432,
758760
/**/
759761
3431,
760762
/**/

0 commit comments

Comments
 (0)