fix(write): show E17 on all platforms #40595

Problems:
On Windows, `:w somedir` (where somedir is an existing directory
in pwd) shows the misleading `E13: File exists (add ! to override)`
instead of `E17: "somedir" is a directory`.

Solution:
drop unnecessary `#ifdef` guard.
This commit is contained in:
Willaaaaaaa
2026-07-20 03:42:59 +08:00
committed by GitHub
parent 7ba955fe07
commit 689b45dda3
2 changed files with 12 additions and 19 deletions

View File

@@ -128,16 +128,14 @@ describe(':write', function()
)
eq('Vim(write):E32: No file name', pcall_err(command, 'write ++p Xotherdir/'))
if not is_os('win') then
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p .')
)
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p ./')
)
end
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p .')
)
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write ++p ./')
)
t.matches(
'E474: Invalid argument',
@@ -149,12 +147,10 @@ describe(':write', function()
command('let $HOME=""')
eq(fn.fnamemodify('.', ':p:h'), fn.fnamemodify('.', ':p:h:~'))
-- Message from check_overwrite
if not is_os('win') then
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write .')
)
end
eq(
('Vim(write):E17: "' .. fn.fnamemodify('.', ':p:h') .. '" is a directory'),
pcall_err(command, 'write .')
)
api.nvim_set_option_value('writeany', true, {})
-- Message from buf_write
eq('Vim(write):E502: "." is a directory', pcall_err(command, 'write .'))