From 85b4b2b788dc04f66246d9a7653370a1e81390c1 Mon Sep 17 00:00:00 2001 From: niten94 Date: Sun, 21 Sep 2025 00:30:07 +0800 Subject: [PATCH] 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. --- internal/action/actions.go | 5 +++++ internal/buffer/save.go | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index be2c1c05..b0867da9 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -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 { diff --git a/internal/buffer/save.go b/internal/buffer/save.go index f0fc6e53..85fa5ed5 100644 --- a/internal/buffer/save.go +++ b/internal/buffer/save.go @@ -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 {