summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-03-12 17:17:31 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-08-15 11:40:40 +0200
commit79c11a045886426482e473cc860b7fa7e4dbd1e6 (patch)
tree4cd18b136e2f22aa77a733326349ca17c8bad944 /pkg/gui/context
parent4a4afc463994658f719ba5a09fb41fae06207bdd (diff)
If selected line is outside, move it to the middle of the view
Previously, the current line was only moved as much as necessary so that it's in view again. This had the problem that when jumping downwards from hunk to hunk with the right-arrow key, only the first line of the new hunk was shown at the bottom of the window. I prefer to put the selected line in the middle of the view in this case, so that I can see more of the newly selected hunk. This has the consequence that when scrolling through the view line by line using down-arrow, the view jumps by half a screen whenever I reach the bottom. I can see how some users might be opposed to this change, but I happen to like it too, because it allows me to see more context of what's ahead.
Diffstat (limited to 'pkg/gui/context')
-rw-r--r--pkg/gui/context/patch_explorer_context.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go
index 17ecae4ae..54a9356ac 100644
--- a/pkg/gui/context/patch_explorer_context.go
+++ b/pkg/gui/context/patch_explorer_context.go
@@ -109,8 +109,9 @@ func (self *PatchExplorerContext) FocusSelection() {
_, viewHeight := view.Size()
bufferHeight := viewHeight - 1
_, origin := view.Origin()
+ numLines := view.LinesHeight()
- newOriginY := state.CalculateOrigin(origin, bufferHeight)
+ newOriginY := state.CalculateOrigin(origin, bufferHeight, numLines)
_ = view.SetOriginY(newOriginY)