Disable sudo save prompt on Windows

Display message stating that saving with sudo is unsupported on Windows,
immediately without a prompt when permission is denied.
This commit is contained in:
niten94
2025-09-21 00:30:07 +08:00
parent ad24089e4e
commit 85b4b2b788
2 changed files with 5 additions and 3 deletions

View File

@@ -1038,6 +1038,11 @@ func (h *BufPane) saveBufToFile(filename string, action string, callback func())
err := h.Buf.SaveAs(filename)
if err != nil {
if errors.Is(err, fs.ErrPermission) {
if runtime.GOOS == "windows" {
InfoBar.Error("Permission denied. Save with sudo not supported on Windows")
return true
}
saveWithSudo := func() {
err = h.Buf.SaveAsWithSudo(filename)
if err != nil {

View File

@@ -246,9 +246,6 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error
if b.Type.Scratch {
return errors.New("Cannot save scratch buffer")
}
if withSudo && runtime.GOOS == "windows" {
return errors.New("Save with sudo not supported on Windows")
}
if !autoSave && b.Settings["rmtrailingws"].(bool) {
for i, l := range b.lines {