From b9d57fa107a456596e68d2ee3853ba75142a6930 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 13 Sep 2021 10:00:09 +0200 Subject: vim-patch:8.2.3432: octave/Matlab filetype detection does not work properly (#15652) Problem: Octave/Matlab filetype detection does not work properly. Solution: Update the patterns used for matching. (Doug Kearns) https://github.com/vim/vim/commit/ca0627df69c29508f6f797bef27a1f5fa9a447d3 --- runtime/autoload/dist/ft.vim | 6 +++--- src/nvim/testdir/test_filetype.vim | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 48a9657cf5..7484149a26 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -269,7 +269,8 @@ func dist#ft#FTm() return endif - let octave_block_terminators = '\' + " excluding end(for|function|if|switch|while) common to Murphi + let octave_block_terminators = '\' 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 diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index ed9bcf2720..cc789cb6bd 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -868,16 +868,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) @@ -888,7 +878,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! @@ -900,6 +890,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') -- cgit