-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Rework filetype change, reload command and autosave
#3343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9afcb80
action/command: Let `reload` really reload the `settings.json`
JoeKar 7f6e5bc
action/command: On `reload` check and inform about errors
JoeKar c51f848
action/command: On `reload` prevent overwriting `settings.json`
JoeKar c67a30e
action/command: On `reload` prevent overwriting volatile settings
JoeKar 62c1c66
buffer/settings: On `filetype` change remove the following steps
JoeKar 521b63a
buffer/settings: On `filetype` change reload parsed local settings only
JoeKar c741e36
action/command: Prevent setting of unchanged option
JoeKar 395d848
buffer/settings: Prevent setting of unchanged option
JoeKar 4663927
config: Refactor parsed option handling
JoeKar f661b64
config/settings: Remove duplicating `DefaultGlobalSettings()`
JoeKar 0552959
action/command: Prevent overwriting settings set locally or by plugin
JoeKar 724e294
action/command: On `reload` prevent overwriting local settings
JoeKar a3071b1
action/command: Refactor `reload` & the `filetype` change
JoeKar 10511c9
buffer/buffer: Store `fileformat` in `LocalSettings` on auto detection
JoeKar 0542765
action/command: Simplify `ResetCmd`
JoeKar a678d42
plugins/comment: Don't write to `b.Settings` directly
JoeKar 832c7de
config: Remove unused `GetAutoTime()`
JoeKar 4170df8
config: Use `float64` within the `autosave` processing
JoeKar 8b31dc7
config: Rework `autosave` to be rearmed upon change
JoeKar 33b7c9d
config: Don't truncate `float64` to `int`
JoeKar b80ea93
config: Correct typo in `validatePositiveValue()`
JoeKar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,49 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "sync" | ||
| "time" | ||
| ) | ||
|
|
||
| var Autosave chan bool | ||
| var autotime int | ||
|
|
||
| // lock for autosave | ||
| var autolock sync.Mutex | ||
| var autotime chan float64 | ||
|
|
||
| func init() { | ||
| Autosave = make(chan bool) | ||
| autotime = make(chan float64) | ||
| } | ||
|
|
||
| func SetAutoTime(a int) { | ||
| autolock.Lock() | ||
| autotime = a | ||
| autolock.Unlock() | ||
| } | ||
|
|
||
| func GetAutoTime() int { | ||
| autolock.Lock() | ||
| a := autotime | ||
| autolock.Unlock() | ||
| return a | ||
| func SetAutoTime(a float64) { | ||
| autotime <- a | ||
| } | ||
|
|
||
| func StartAutoSave() { | ||
| go func() { | ||
| var a float64 | ||
| var t *time.Timer | ||
| var elapsed <-chan time.Time | ||
| for { | ||
| autolock.Lock() | ||
| a := autotime | ||
| autolock.Unlock() | ||
| if a < 1 { | ||
| break | ||
| select { | ||
| case a = <-autotime: | ||
| if t != nil { | ||
| t.Stop() | ||
| for len(elapsed) > 0 { | ||
| <-elapsed | ||
| } | ||
| } | ||
| if a > 0 { | ||
| if t != nil { | ||
| t.Reset(time.Duration(a * float64(time.Second))) | ||
| } else { | ||
| t = time.NewTimer(time.Duration(a * float64(time.Second))) | ||
| elapsed = t.C | ||
| } | ||
| } | ||
| case <-elapsed: | ||
| if a > 0 { | ||
| t.Reset(time.Duration(a * float64(time.Second))) | ||
| Autosave <- true | ||
| } | ||
| } | ||
| time.Sleep(time.Duration(a) * time.Second) | ||
| Autosave <- true | ||
| } | ||
| }() | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.