aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/vim/filetype/detect.lua10
-rw-r--r--test/old/testdir/test_filetype.vim16
2 files changed, 5 insertions, 21 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index b3d9fedeae..d1eabadc4a 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -473,12 +473,12 @@ function M.fs(bufnr)
if vim.g.filetype_fs then
return vim.g.filetype_fs
end
- local line = nextnonblank(bufnr, 1)
- if findany(line, { '^%s*%.?%( ', '^%s*\\G? ', '^\\$', '^%s*: %S' }) then
- return 'forth'
- else
- return 'fsharp'
+ for _, line in ipairs(getlines(bufnr, 1, 100)) do
+ if line:find('^[:(\\] ') then
+ return 'forth'
+ end
end
+ return 'fsharp'
end
function M.git(bufnr)
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index 23adff3d3d..776aaae4ac 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -1227,27 +1227,11 @@ func Test_fs_file()
call assert_equal('forth', &filetype)
bwipe!
- call writefile(['.( Forth displayed inline comment )'], 'Xfile.fs')
- split Xfile.fs
- call assert_equal('forth', &filetype)
- bwipe!
-
call writefile(['\ Forth line comment'], 'Xfile.fs')
split Xfile.fs
call assert_equal('forth', &filetype)
bwipe!
- " empty line comment - no space required
- call writefile(['\'], 'Xfile.fs')
- split Xfile.fs
- call assert_equal('forth', &filetype)
- bwipe!
-
- call writefile(['\G Forth documentation comment '], 'Xfile.fs')
- split Xfile.fs
- call assert_equal('forth', &filetype)
- bwipe!
-
call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.fs')
split Xfile.fs
call assert_equal('forth', &filetype)