Relocate buffer view after setting options that affect it#3743
Relocate buffer view after setting options that affect it#3743dmaluka merged 1 commit intomicro-editor:masterfrom
Conversation
Whenever the user changes the value of an option that affects the calculation of display params in updateDisplayInfo(), we should immediately recalculate those params and relocate the buffer view accordingly. For example: after enabling ruler via `set ruler on`, if the cursor is currently at the rightmost edge of the bufpane and softwrap is disabled, then the cursor becomes invisible (since it is now outside the view, since the buffer view width is decreased as a result of adding the ruler but StartCol is not updated accordingly), it only becomes visible again after the user types a character (or performs some other action that triggers updateDisplayInfo() + relocate). Fix it.
421d781 to
9f7dec7
Compare
| if option == "diffgutter" || option == "ruler" || option == "scrollbar" || | ||
| option == "statusline" { |
There was a problem hiding this comment.
Would fit for now, but I fear this will be forgotten in case we add further options affecting the window parameters.
So maybe move it into a method of the BufWindow e.g.:
if isAffectingWindow(option) {
w.updateDisplayInfo()
w.Relocate()
}func (w *BufWindow) isAffectingWindow(option string) bool {
if option == "diffgutter" || option == "ruler" || option == "scrollbar" ||
option == "statusline" {
return true
}
return false
}There was a problem hiding this comment.
Maybe, OTOH we would still need to update that in 2 places. And it would make it less explicit which exact options we are dealing with here, in SetBuffer() (so e.g. if we for whatever reason add some of these options also to the above if, or to some new if that also does relocate, it will be not so obvious that we needlessly do relocate twice...)
Also note that technically infobar and keymenu affect window too, but we already handle them in a different way, by ensuring Tabs.Resize() after setting them (since they are global settings affecting all windows), which already calls updateDisplayInfo() and Relocate() for all affected windows, so we don't need to do that here.
…or#3743) Whenever the user changes the value of an option that affects the calculation of display params in updateDisplayInfo(), we should immediately recalculate those params and relocate the buffer view accordingly. For example: after enabling ruler via `set ruler on`, if the cursor is currently at the rightmost edge of the bufpane and softwrap is disabled, then the cursor becomes invisible (since it is now outside the view, since the buffer view width is decreased as a result of adding the ruler but StartCol is not updated accordingly), it only becomes visible again after the user types a character (or performs some other action that triggers updateDisplayInfo() + relocate). Fix it.
Whenever the user changes the value of an option that affects the calculation of display params in
updateDisplayInfo(), we should immediately recalculate those params and relocate the buffer view accordingly.For example: after enabling ruler via
set ruler on, if the cursor is currently at the rightmost edge of the bufpane and softwrap is disabled, then the cursor becomes invisible (since it is now outside the view, since the buffer view width is decreased as a result of adding the ruler butStartColis not updated accordingly), it only becomes visible again after the user types a character (or performs some other action that triggersupdateDisplayInfo()+ relocate). Fix it.Somewhat related to #3741