mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.0.1438: .fs files are falsely recognized as forth files (#22871)
Problem: .fs files are falsely recognized as forth files.
Solution: Check 100 lines for something that looks like forth. (Johan
Kotlinski, closes vim/vim#12219, closes vim/vim#11988)
065088d554
Co-authored-by: Johan Kotlinski <kotlinski@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user