Prompt on save/ existing file
* Update for fixing bug issue
Adds YNprompt when user tries save new file as existing file name in current directory.
* Update actions.go
error handled. gonna have to be tested on permission errors, etc
@@ -791,11 +791,28 @@ func (h *BufPane) SaveAsCB(action string, callback func()) bool {
return
}
filename := strings.Join(args, " ")
+ fileinfo, err := os.Stat(filename)
+ if err != nil {
+ if os.IsNotExist(err) {
+ noPrompt := h.saveBufToFile(filename, action, callback)
+ if noPrompt {
+ h.completeAction(action)
+ return
+ }
+ }
+ }
+ InfoBar.YNPrompt(
+ fmt.Sprintf("the file %s already exists in the directory, would you like to overwrite? Y/n", fileinfo.Name()),
+ func(yes, canceled bool) {
+ if yes && !canceled {
noPrompt := h.saveBufToFile(filename, action, callback)
if noPrompt {
h.completeAction(action)
}
}
+ },
+ )
+ }
})
return false
}
