mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 06:30:28 +09:00
config: Use float64 within the autosave processing
This commit is contained in:
@@ -357,7 +357,7 @@ func main() {
|
||||
}
|
||||
|
||||
if a := config.GetGlobalOption("autosave").(float64); a > 0 {
|
||||
config.SetAutoTime(int(a))
|
||||
config.SetAutoTime(a)
|
||||
config.StartAutoSave()
|
||||
}
|
||||
|
||||
|
||||
@@ -552,7 +552,7 @@ func doSetGlobalOptionNative(option string, nativeValue interface{}) error {
|
||||
}
|
||||
} else if option == "autosave" {
|
||||
if nativeValue.(float64) > 0 {
|
||||
config.SetAutoTime(int(nativeValue.(float64)))
|
||||
config.SetAutoTime(nativeValue.(float64))
|
||||
config.StartAutoSave()
|
||||
} else {
|
||||
config.SetAutoTime(0)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
var Autosave chan bool
|
||||
var autotime int
|
||||
var autotime float64
|
||||
|
||||
// lock for autosave
|
||||
var autolock sync.Mutex
|
||||
@@ -15,7 +15,7 @@ func init() {
|
||||
Autosave = make(chan bool)
|
||||
}
|
||||
|
||||
func SetAutoTime(a int) {
|
||||
func SetAutoTime(a float64) {
|
||||
autolock.Lock()
|
||||
autotime = a
|
||||
autolock.Unlock()
|
||||
@@ -27,10 +27,10 @@ func StartAutoSave() {
|
||||
autolock.Lock()
|
||||
a := autotime
|
||||
autolock.Unlock()
|
||||
if a < 1 {
|
||||
if a <= 0 {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Duration(a) * time.Second)
|
||||
time.Sleep(time.Duration(a * float64(time.Second)))
|
||||
Autosave <- true
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user