From 8c883c6210d229b47488a85041afcd41d2e65de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Wed, 30 Oct 2024 19:36:14 +0100 Subject: [PATCH] backup: Rearrange and extend `BackupMsg` --- cmd/micro/micro.go | 2 +- internal/buffer/backup.go | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index c1ceb796..b9cb76c2 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -230,7 +230,7 @@ func checkBackup(name string) error { input, err := os.ReadFile(backup) if err == nil { 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) if choice%3 == 0 { diff --git a/internal/buffer/backup.go b/internal/buffer/backup.go index 2a05c38c..305d5694 100644 --- a/internal/buffer/backup.go +++ b/internal/buffer/backup.go @@ -14,11 +14,15 @@ import ( "github.com/zyedidia/micro/v2/internal/util" ) -const BackupMsg = `A backup was detected for this file. This likely means that micro -crashed while editing this file, or another instance of micro is currently -editing this file. +const BackupMsg = `A backup was detected for: -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 @@ -131,7 +135,7 @@ func (b *Buffer) ApplyBackup(fsize int64) (bool, bool) { if err == nil { defer backup.Close() 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) if choice%3 == 0 {