diff options
| author | elianiva <dicha.arkana03@gmail.com> | 2021-02-24 21:40:11 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-24 21:40:11 +0700 |
| commit | 8b3d08d7a6e8eccc2997ccbf91a7e12d506196e5 (patch) | |
| tree | 46c00cfe4d97351a7c0041e7b17f72fd45def20b /lua/telescope/pickers/scroller.lua | |
| parent | b5051eeb01bfbff2df2b46f59c13318987ed1e59 (diff) | |
fix: scroll misbehaving + fixed jump to middle (#547)
* fix: scroll misbehaving + fixed jump to middle
* add test
* fixx
* fix nil
Diffstat (limited to 'lua/telescope/pickers/scroller.lua')
| -rw-r--r-- | lua/telescope/pickers/scroller.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lua/telescope/pickers/scroller.lua b/lua/telescope/pickers/scroller.lua index d330dec..b77fc96 100644 --- a/lua/telescope/pickers/scroller.lua +++ b/lua/telescope/pickers/scroller.lua @@ -81,7 +81,15 @@ scroller.top = function(sorting_strategy, max_results, num_results) end scroller.middle = function(sorting_strategy, max_results, num_results) - return math.floor(max_results/2) + local mid_pos + + if sorting_strategy == 'ascending' then + mid_pos = math.floor(num_results / 2) + else + mid_pos = math.floor(max_results - num_results / 2) + end + + return (num_results < max_results) and mid_pos or math.floor(max_results / 2) end scroller.bottom = function(sorting_strategy, max_results, num_results) |
