fix(filetype): fix :filetype detect error with -u NONE (#29991)

:filetype detect should enable filetype detection when it hasn't been
enabled before.
This commit is contained in:
zeertzjq 2024-08-06 22:20:26 +08:00 committed by GitHub
parent 37952bf7b4
commit 93347a67bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -7330,7 +7330,7 @@ static void ex_filetype(exarg_T *eap)
break; break;
} }
if (strcmp(arg, "on") == 0 || strcmp(arg, "detect") == 0) { if (strcmp(arg, "on") == 0 || strcmp(arg, "detect") == 0) {
if (*arg == 'o' || !filetype_detect) { if (*arg == 'o' || filetype_detect != kTrue) {
source_runtime(FILETYPE_FILE, DIP_ALL); source_runtime(FILETYPE_FILE, DIP_ALL);
filetype_detect = kTrue; filetype_detect = kTrue;
if (plugin) { if (plugin) {

View File

@ -112,6 +112,13 @@ describe('startup', function()
|*2 |*2
]]) ]])
end) end)
it(':filetype detect enables filetype detection with -u NONE', function()
clear()
eq('filetype detection:OFF plugin:OFF indent:OFF', exec_capture('filetype'))
command('filetype detect')
eq('filetype detection:ON plugin:OFF indent:OFF', exec_capture('filetype'))
end)
end) end)
describe('startup', function() describe('startup', function()