Skip to content

Commit

Permalink
Picker option push_cursor_on_edit.
Browse files Browse the repository at this point in the history
  • Loading branch information
caojoshua committed Dec 2, 2021
1 parent 1c57cc6 commit c81375e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/telescope/actions/set.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ action_set.edit = function(prompt_bufnr, command)

local entry_bufnr = entry.bufnr

local picker = action_state.get_current_picker(prompt_bufnr)
require("telescope.actions").close(prompt_bufnr)

if picker.push_cursor_on_edit then
vim.cmd "normal! m'"
end

if entry_bufnr then
edit_buffer(command, entry_bufnr)
else
Expand Down
10 changes: 10 additions & 0 deletions lua/telescope/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,16 @@ append(
Default: require("telescope.previewers").buffer_previewer_maker]]
)

append(
"push_cursor_on_edit",
false,
[[
Push the position of the cursor before starting the Telescope picker
onto the jumplist when choosing an edit action.
Default: false]]
)

-- @param user_defaults table: a table where keys are the names of options,
-- and values are the ones the user wants
-- @param tele_defaults table: (optional) a table containing all of the defaults
Expand Down
2 changes: 2 additions & 0 deletions lua/telescope/pickers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function Picker:new(opts)
sorting_strategy = get_default(opts.sorting_strategy, config.values.sorting_strategy),
selection_strategy = get_default(opts.selection_strategy, config.values.selection_strategy),

push_cursor_on_edit = get_default(opts.push_cursor_on_edit, config.values.push_cursor_on_edit),

layout_strategy = layout_strategy,
layout_config = config.smarter_depth_2_extend(opts.layout_config or {}, config.values.layout_config or {}),

Expand Down

0 comments on commit c81375e

Please sign in to comment.