Skip to content

Commit 4170df8

Browse files
committed
config: Use float64 within the autosave processing
1 parent 832c7de commit 4170df8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cmd/micro/micro.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func main() {
357357
}
358358

359359
if a := config.GetGlobalOption("autosave").(float64); a > 0 {
360-
config.SetAutoTime(int(a))
360+
config.SetAutoTime(a)
361361
config.StartAutoSave()
362362
}
363363

internal/action/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func doSetGlobalOptionNative(option string, nativeValue interface{}) error {
552552
}
553553
} else if option == "autosave" {
554554
if nativeValue.(float64) > 0 {
555-
config.SetAutoTime(int(nativeValue.(float64)))
555+
config.SetAutoTime(nativeValue.(float64))
556556
config.StartAutoSave()
557557
} else {
558558
config.SetAutoTime(0)

internal/config/autosave.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
var Autosave chan bool
9-
var autotime int
9+
var autotime float64
1010

1111
// lock for autosave
1212
var autolock sync.Mutex
@@ -15,7 +15,7 @@ func init() {
1515
Autosave = make(chan bool)
1616
}
1717

18-
func SetAutoTime(a int) {
18+
func SetAutoTime(a float64) {
1919
autolock.Lock()
2020
autotime = a
2121
autolock.Unlock()
@@ -27,10 +27,10 @@ func StartAutoSave() {
2727
autolock.Lock()
2828
a := autotime
2929
autolock.Unlock()
30-
if a < 1 {
30+
if a <= 0 {
3131
break
3232
}
33-
time.Sleep(time.Duration(a) * time.Second)
33+
time.Sleep(time.Duration(a * float64(time.Second)))
3434
Autosave <- true
3535
}
3636
}()

0 commit comments

Comments
 (0)