File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1251,6 +1251,9 @@ builtin.resume({opts}) *telescope.builtin.resume()*
1251
1251
Options: ~
1252
1252
{cache_index} (number) what picker to resume, where 1 denotes most
1253
1253
recent (default: 1)
1254
+ {select_pos} (number) select the entry that position is specified
1255
+ by this value and do `actions.select_default`
1256
+ (default: nil)
1254
1257
1255
1258
1256
1259
builtin.pickers({opts} ) *telescope.builtin.pickers()*
Original file line number Diff line number Diff line change @@ -148,6 +148,18 @@ internal.resume = function(opts)
148
148
})
149
149
return
150
150
end
151
+ if opts .select_pos then
152
+ if picker .manager :num_results () <= math.abs (opts .select_pos ) then
153
+ utils .notify (" builtin.resume" , {
154
+ msg = string.format (" The picker has less entries than supplied pos: %d" , opts .select_pos ),
155
+ level = " ERROR" ,
156
+ })
157
+ return
158
+ end
159
+ opts ._select_pos = opts .select_pos
160
+ opts .select_pos = nil
161
+ end
162
+
151
163
-- reset layout strategy and get_window_options if default as only one is valid
152
164
-- and otherwise unclear which was actually set
153
165
if picker .layout_strategy == conf .layout_strategy then
Original file line number Diff line number Diff line change @@ -324,6 +324,8 @@ function Picker:new(opts)
324
324
325
325
cache_picker = config .resolve_table_opts (opts .cache_picker , vim .deepcopy (config .values .cache_picker )),
326
326
327
+ _select_pos = opts ._select_pos ,
328
+
327
329
__scrolling_limit = tonumber (vim .F .if_nil (opts .temp__scrolling_limit , 250 )),
328
330
329
331
__locations_input = vim .F .if_nil (opts .__locations_input , false ),
@@ -1708,6 +1710,10 @@ function Picker:_resume_picker()
1708
1710
vim .cmd " do User TelescopeResumePost"
1709
1711
end )
1710
1712
end
1713
+ if self ._select_pos then
1714
+ self :move_selection (self ._select_pos )
1715
+ vim .schedule_wrap (actions .select_default )(self .prompt_bufnr )
1716
+ end
1711
1717
end
1712
1718
-- if text changed, required to set anew to restart finder; otherwise hl and selection
1713
1719
if self .cache_picker .cached_prompt ~= self .default_text then
You can’t perform that action at this time.
0 commit comments