Mercurial > vim
changeset 25794:374adc90efa5 v8.2.3432
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Commit: https://github.com/vim/vim/commit/ca0627df69c29508f6f797bef27a1f5fa9a447d3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 12 17:03:08 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Sep 2021 17:15:02 +0200 |
parents | 163ca9be90bc |
children | f0093634cf43 |
files | runtime/autoload/dist/ft.vim src/testdir/test_filetype.vim src/version.c |
diffstat | 3 files changed, 13 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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 = '\<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
--- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -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')