File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 521521local function scroll_buffer_space ()
522522 if current_top_row ~= previous_top_row and current_line ~= previous_line then
523523 -- Shift to show smear in buffer space instead of screen space
524- local shift = screen .get_screen_distance (previous_top_row , current_top_row )
524+ local shift = screen .get_screen_distance (previous_top_row , current_top_row , current_window_id )
525525 local shifted_position = { current_corners [1 ][1 ] - shift , current_corners [1 ][2 ] }
526526 clamp_to_buffer (shifted_position )
527527 set_corners (current_corners , shifted_position [1 ], shifted_position [2 ])
Original file line number Diff line number Diff line change @@ -36,24 +36,30 @@ M.get_screen_cmd_cursor_position = function()
3636 return row , col
3737end
3838
39- M .get_screen_distance = function (row_start , row_end )
39+ M .get_screen_distance = function (row_start , row_end , window_id )
4040 local reversed = false
4141
4242 if row_start > row_end then
4343 row_start , row_end = row_end , row_start
4444 reversed = true
4545 end
4646
47+ local window_height = vim .api .nvim_win_get_height (window_id )
48+
4749 local text_height
48- local success = pcall (function ()
49- text_height = vim .api .nvim_win_text_height (0 , {
50- start_row = row_start - 1 ,
51- end_row = row_end - 1 ,
52- })
53- end )
54-
55- if not success then -- line is not visible
56- text_height = { all = 1 }
50+ if row_end - row_start >= window_height then
51+ text_height = { all = window_height }
52+ else
53+ local success = pcall (function ()
54+ text_height = vim .api .nvim_win_text_height (0 , {
55+ start_row = row_start - 1 ,
56+ end_row = row_end - 1 ,
57+ })
58+ end )
59+
60+ if not success then -- line is not visible
61+ text_height = { all = 1 }
62+ end
5763 end
5864
5965 local distance = text_height .all - 1
You can’t perform that action at this time.
0 commit comments