diff options
| author | aca <acadx0@gmail.com> | 2020-12-11 12:52:30 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-10 22:52:30 -0500 |
| commit | d9bf9181bccecb774ba7d56cdf5db440547f3b50 (patch) | |
| tree | 09d32bc50e8f77a2d0a1cc12c89c9479e55af2db /lua/telescope/pickers.lua | |
| parent | 62b8655f1532d92245a50ac387201f2d1ac616e1 (diff) | |
fix: cycle scroll when num_results is small (#316)
Diffstat (limited to 'lua/telescope/pickers.lua')
| -rw-r--r-- | lua/telescope/pickers.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 77d183b..ad37f1e 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -696,10 +696,18 @@ end function Picker:_handle_scroll_strategy(row) if self.scroll_strategy == "cycle" then - if row >= self.max_results then - row = 0 - elseif row < 0 then - row = self.max_results - 1 + if self.max_results > self.manager:num_results() then + if row < self.max_results - self.manager:num_results() then + row = self.max_results - 1 + elseif row > self.max_results - 1 then + row = self.max_results - self.manager:num_results() + end + else + if row >= self.max_results then + row = 0 + elseif row < 0 then + row = self.max_results - 1 + end end else if row >= self.max_results then |
