@@ -181,6 +181,7 @@ function Picker:is_done()
181181 end
182182end
183183
184+ -- TODO(scroll)
184185function Picker :clear_extra_rows (results_bufnr )
185186 if self :is_done () then
186187 log .trace " Not clearing due to being already complete"
@@ -219,21 +220,6 @@ function Picker:clear_extra_rows(results_bufnr)
219220 log .trace (" Clearing:" , worst_line )
220221end
221222
222- function Picker :highlight_displayed_rows (results_bufnr , prompt )
223- if not self .sorter or not self .sorter .highlighter then
224- return
225- end
226-
227- vim .api .nvim_buf_clear_namespace (results_bufnr , ns_telescope_matching , 0 , - 1 )
228-
229- local displayed_rows = vim .api .nvim_buf_get_lines (results_bufnr , 0 , - 1 , false )
230- for row_index = 1 , math.min (# displayed_rows , self .max_results ) do
231- local display = displayed_rows [row_index ]
232-
233- self :highlight_one_row (results_bufnr , prompt , display , row_index - 1 )
234- end
235- end
236-
237223function Picker :highlight_one_row (results_bufnr , prompt , display , row )
238224 local highlights = self .sorter :highlighter (prompt , display )
239225
@@ -278,6 +264,8 @@ function Picker:_next_find_id()
278264end
279265
280266function Picker :find ()
267+ self .result_limit = 100000
268+
281269 self :close_existing_pickers ()
282270 self :reset_selection ()
283271
@@ -353,7 +341,7 @@ function Picker:find()
353341 self :_reset_prefix_color ()
354342
355343 -- First thing we want to do is set all the lines to blank.
356- self .max_results = popup_opts .results .height
344+ self .max_results = 10000 or popup_opts .results .height
357345
358346 -- TODO(scrolling): This may be a hack when we get a little further into implementing scrolling.
359347 vim .api .nvim_buf_set_lines (results_bufnr , 0 , self .max_results , false , utils .repeated_table (self .max_results , " " ))
@@ -431,6 +419,7 @@ function Picker:find()
431419 self .sorter :_start (prompt )
432420 self .manager = EntryManager :new (self .max_results , self .entry_adder , self .stats )
433421
422+ vim .api .nvim_buf_clear_namespace (results_bufnr , ns_telescope_matching , 0 , - 1 )
434423 local process_result = self :get_result_processor (find_id , prompt , debounced_status )
435424 local process_complete = self :get_result_completor (self .results_bufnr , find_id , prompt , status_updater )
436425
@@ -461,7 +450,6 @@ function Picker:find()
461450 else
462451 -- scheduling required to apply highlighting and selection appropriately
463452 await_schedule (function ()
464- self :highlight_displayed_rows (self .results_bufnr , self .cache_picker .cached_prompt )
465453 if self .cache_picker .selection_row ~= nil then
466454 self :set_selection (self .cache_picker .selection_row )
467455 end
@@ -856,6 +844,8 @@ function Picker:set_selection(row)
856844 self ._selection_row = row
857845
858846 self :refresh_previewer ()
847+
848+ vim .api .nvim_win_set_cursor (self .results_win , { row + 1 , 0 })
859849end
860850
861851function Picker :refresh_previewer ()
@@ -942,6 +932,7 @@ function Picker:entry_adder(index, entry, _, insert)
942932 local set_ok , msg = pcall (vim .api .nvim_buf_set_lines , self .results_bufnr , row , row + offset , false , { display })
943933 if set_ok and display_highlights then
944934 self .highlighter :hi_display (row , prefix , display_highlights )
935+ self :highlight_one_row (self .results_bufnr , self :_get_prompt (), display , row )
945936 end
946937
947938 if not set_ok then
@@ -1025,9 +1016,17 @@ function Picker:get_status_updater(prompt_win, prompt_bufnr)
10251016end
10261017
10271018function Picker :get_result_processor (find_id , prompt , status_updater )
1019+ local stopped = false
1020+ local added = 0
1021+
10281022 local cb_add = function (score , entry )
10291023 self .manager :add_entry (self , score , entry )
10301024 status_updater { completed = false }
1025+
1026+ added = added + 1
1027+ if added > self .result_limit then
1028+ stopped = true
1029+ end
10311030 end
10321031
10331032 local cb_filter = function (_ )
@@ -1039,6 +1038,10 @@ function Picker:get_result_processor(find_id, prompt, status_updater)
10391038 return true
10401039 end
10411040
1041+ if stopped then
1042+ return true
1043+ end
1044+
10421045 self :_increment " processed"
10431046
10441047 if not entry or entry .valid == false then
@@ -1075,7 +1078,6 @@ function Picker:get_result_completor(results_bufnr, find_id, prompt, status_upda
10751078 status_updater { completed = true }
10761079
10771080 self :clear_extra_rows (results_bufnr )
1078- self :highlight_displayed_rows (results_bufnr , prompt )
10791081 self .sorter :_finish (prompt )
10801082
10811083 self :_on_complete ()
0 commit comments