Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/display/bufwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
c.LastWrappedVisualX = c.GetVisualX(true)
}
}

if option == "diffgutter" || option == "ruler" || option == "scrollbar" ||
option == "statusline" {
Comment on lines +65 to +66
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, convinced me. 👍

w.updateDisplayInfo()
w.Relocate()
}
}
b.GetVisualX = func(loc buffer.Loc) int {
return w.VLocFromLoc(loc).VisualX
Expand Down