mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 14:55:38 -04:00
actions: Use SetOptionNative()
instead of setting options directly
Setting options directly in (h.)Buf.Settings without calling SetOption() or SetOptionNative() is generally not the best idea, since it may not trigger the needed side effects. In particular, after https://github.com/zyedidia/micro/pull/3343, directly setting `diffgutter` and `ruler` causes them not being tracked as locally overridden per buffer, so if we run the `reload` command, it unexpectedly replaces them with the default ones.
This commit is contained in:
parent
2e94235905
commit
ddc6051b33
@ -1794,12 +1794,12 @@ func (h *BufPane) HalfPageDown() bool {
|
||||
|
||||
// ToggleDiffGutter turns the diff gutter off and on
|
||||
func (h *BufPane) ToggleDiffGutter() bool {
|
||||
if !h.Buf.Settings["diffgutter"].(bool) {
|
||||
h.Buf.Settings["diffgutter"] = true
|
||||
diffgutter := !h.Buf.Settings["diffgutter"].(bool)
|
||||
h.Buf.SetOptionNative("diffgutter", diffgutter)
|
||||
if diffgutter {
|
||||
h.Buf.UpdateDiff()
|
||||
InfoBar.Message("Enabled diff gutter")
|
||||
} else {
|
||||
h.Buf.Settings["diffgutter"] = false
|
||||
InfoBar.Message("Disabled diff gutter")
|
||||
}
|
||||
return true
|
||||
@ -1807,11 +1807,11 @@ func (h *BufPane) ToggleDiffGutter() bool {
|
||||
|
||||
// ToggleRuler turns line numbers off and on
|
||||
func (h *BufPane) ToggleRuler() bool {
|
||||
if !h.Buf.Settings["ruler"].(bool) {
|
||||
h.Buf.Settings["ruler"] = true
|
||||
ruler := !h.Buf.Settings["ruler"].(bool)
|
||||
h.Buf.SetOptionNative("ruler", ruler)
|
||||
if ruler {
|
||||
InfoBar.Message("Enabled ruler")
|
||||
} else {
|
||||
h.Buf.Settings["ruler"] = false
|
||||
InfoBar.Message("Disabled ruler")
|
||||
}
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user