Skip to content

Commit e127f08

Browse files
committed
On panic, backup modified buffers only
1 parent 7aa495f commit e127f08

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cmd/micro/micro.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,11 @@ func main() {
352352
} else {
353353
fmt.Println("Micro encountered an error:", errors.Wrap(err, 2).ErrorStack(), "\nIf you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues")
354354
}
355-
// backup all open buffers
355+
// immediately backup all buffers with unsaved changes
356356
for _, b := range buffer.OpenBuffers {
357-
b.Backup()
357+
if b.Modified() {
358+
b.Backup()
359+
}
358360
}
359361
exit(1)
360362
}

cmd/micro/micro_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ func startup(args []string) (tcell.SimulationScreen, error) {
5555
if err := recover(); err != nil {
5656
screen.Screen.Fini()
5757
fmt.Println("Micro encountered an error:", err)
58-
// backup all open buffers
58+
// immediately backup all buffers with unsaved changes
5959
for _, b := range buffer.OpenBuffers {
60-
b.Backup()
60+
if b.Modified() {
61+
b.Backup()
62+
}
6163
}
6264
// Print the stack trace too
6365
log.Fatalf(errors.Wrap(err, 2).ErrorStack())

0 commit comments

Comments
 (0)