mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
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.
This commit is contained in:
parent
4a4afc4639
commit
79c11a0458
4 changed files with 44 additions and 15 deletions
|
@ -216,8 +216,8 @@ func (s *State) SelectTop() {
|
|||
s.SelectLine(0)
|
||||
}
|
||||
|
||||
func (s *State) CalculateOrigin(currentOrigin int, bufferHeight int) int {
|
||||
func (s *State) CalculateOrigin(currentOrigin int, bufferHeight int, numLines int) int {
|
||||
firstLineIdx, lastLineIdx := s.SelectedRange()
|
||||
|
||||
return calculateOrigin(currentOrigin, bufferHeight, firstLineIdx, lastLineIdx, s.GetSelectedLineIdx(), s.selectMode)
|
||||
return calculateOrigin(currentOrigin, bufferHeight, numLines, firstLineIdx, lastLineIdx, s.GetSelectedLineIdx(), s.selectMode)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue