mirror of
https://github.com/zyedidia/micro
synced 2024-11-05 17:41:24 +00:00
No backups for no name files
This commit is contained in:
parent
c4d5d7c195
commit
fc706bc404
7 changed files with 18 additions and 11 deletions
|
@ -70,7 +70,7 @@ func InitFlags() {
|
|||
// If -options was passed
|
||||
var keys []string
|
||||
m := config.DefaultAllSettings()
|
||||
for k, _ := range m {
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
@ -134,6 +134,13 @@ func LoadInput() []*buffer.Buffer {
|
|||
}
|
||||
|
||||
func main() {
|
||||
defer os.Exit(0)
|
||||
|
||||
// runtime.SetCPUProfileRate(400)
|
||||
// f, _ := os.Create("micro.prof")
|
||||
// pprof.StartCPUProfile(f)
|
||||
// defer pprof.StopCPUProfile()
|
||||
|
||||
var err error
|
||||
|
||||
InitLog()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package action
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
@ -1167,7 +1167,7 @@ func (h *BufPane) Quit() bool {
|
|||
} else {
|
||||
screen.Screen.Fini()
|
||||
InfoBar.Close()
|
||||
os.Exit(0)
|
||||
runtime.Goexit()
|
||||
}
|
||||
}
|
||||
if h.Buf.Modified() {
|
||||
|
@ -1207,7 +1207,7 @@ func (h *BufPane) QuitAll() bool {
|
|||
}
|
||||
screen.Screen.Fini()
|
||||
InfoBar.Close()
|
||||
os.Exit(0)
|
||||
runtime.Goexit()
|
||||
}
|
||||
|
||||
if anyModified {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package action
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/zyedidia/clipboard"
|
||||
"github.com/zyedidia/micro/internal/display"
|
||||
|
@ -47,7 +47,7 @@ func (t *TermPane) Quit() {
|
|||
} else {
|
||||
screen.Screen.Fini()
|
||||
InfoBar.Close()
|
||||
os.Exit(0)
|
||||
runtime.Goexit()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Options: [r]ecover, [i]gnore: `
|
|||
|
||||
// Backup saves the current buffer to ConfigDir/backups
|
||||
func (b *Buffer) Backup(checkTime bool) error {
|
||||
if !b.Settings["backup"].(bool) {
|
||||
if !b.Settings["backup"].(bool) || b.Path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ func (b *Buffer) Backup(checkTime bool) error {
|
|||
|
||||
// RemoveBackup removes any backup file associated with this buffer
|
||||
func (b *Buffer) RemoveBackup() {
|
||||
if !b.Settings["backup"].(bool) {
|
||||
if !b.Settings["backup"].(bool) || b.Path == "" {
|
||||
return
|
||||
}
|
||||
f := config.ConfigDir + "/backups/" + util.EscapePath(b.AbsPath)
|
||||
|
|
|
@ -204,7 +204,7 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
|
|||
b.SharedBuffer = new(SharedBuffer)
|
||||
b.Type = btype
|
||||
|
||||
if b.Settings["backup"].(bool) {
|
||||
if b.Settings["backup"].(bool) && len(path) > 0 {
|
||||
backupfile := config.ConfigDir + "/backups/" + EscapePath(absPath)
|
||||
if info, err := os.Stat(backupfile); err == nil {
|
||||
backup, err := os.Open(backupfile)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -58,7 +58,7 @@ func (i *InfoBuf) Message(msg ...interface{}) {
|
|||
displayMessage := fmt.Sprint(msg...)
|
||||
// if there is no active prompt then style and display the message as normal
|
||||
i.Msg = displayMessage
|
||||
i.HasMessage = true
|
||||
i.HasMessage, i.HasError = true, false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue