backup: Rearrange and extend BackupMsg

This commit is contained in:
Jöran Karl 2024-10-30 19:36:14 +01:00
parent c4dcef3e66
commit 8c883c6210
2 changed files with 10 additions and 6 deletions

View File

@ -230,7 +230,7 @@ func checkBackup(name string) error {
input, err := os.ReadFile(backup) input, err := os.ReadFile(backup)
if err == nil { if err == nil {
t := info.ModTime() t := info.ModTime()
msg := fmt.Sprintf(buffer.BackupMsg, t.Format("Mon Jan _2 at 15:04, 2006"), backup) msg := fmt.Sprintf(buffer.BackupMsg, target, t.Format("Mon Jan _2 at 15:04, 2006"), backup)
choice := screen.TermPrompt(msg, []string{"r", "i", "a", "recover", "ignore", "abort"}, true) choice := screen.TermPrompt(msg, []string{"r", "i", "a", "recover", "ignore", "abort"}, true)
if choice%3 == 0 { if choice%3 == 0 {

View File

@ -14,11 +14,15 @@ import (
"github.com/zyedidia/micro/v2/internal/util" "github.com/zyedidia/micro/v2/internal/util"
) )
const BackupMsg = `A backup was detected for this file. This likely means that micro const BackupMsg = `A backup was detected for:
crashed while editing this file, or another instance of micro is currently
editing this file.
The backup was created on %s, and the file is %s
This likely means that micro crashed while editing this file,
or another instance of micro is currently editing this file,
or an error occurred while saving this file so it may be corrupted.
The backup was created on %s and its path is:
%s %s
@ -131,7 +135,7 @@ func (b *Buffer) ApplyBackup(fsize int64) (bool, bool) {
if err == nil { if err == nil {
defer backup.Close() defer backup.Close()
t := info.ModTime() t := info.ModTime()
msg := fmt.Sprintf(BackupMsg, t.Format("Mon Jan _2 at 15:04, 2006"), backupfile) msg := fmt.Sprintf(BackupMsg, b.Path, t.Format("Mon Jan _2 at 15:04, 2006"), backupfile)
choice := screen.TermPrompt(msg, []string{"r", "i", "a", "recover", "ignore", "abort"}, true) choice := screen.TermPrompt(msg, []string{"r", "i", "a", "recover", "ignore", "abort"}, true)
if choice%3 == 0 { if choice%3 == 0 {