Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let user configure how select_default will edit file: edit, new, vnew or tabedit #3195

Open
powerman opened this issue Jul 1, 2024 · 0 comments
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@powerman
Copy link

powerman commented Jul 1, 2024

Is your feature request related to a problem? Please describe.
I'm get used to avoid multiple windows and always open new files in a tabs, so I'd like to use <Enter> to open files in a tab instead of split window - it's much more convenient than <C-T>.

The problem is current select_default action does two things: open Telescope submenu or open files.
Because of this trivial solution "just remap <Enter> to select_tab" breaks all menu items which are not a file to be opened (e.g. colorshemes, etc.).

Describe the solution you'd like
Add a setup option with one of "edit", "new", "vnew" or "tabedit" values to configure select_default action.

Describe alternatives you've considered
We can monkey-patch to make this work. But, as usually, monkey-patch is complicated and fragile workaround.

-- Force opening files in a new tab.
local actions_state = require 'telescope.actions.state'
local select_key_to_edit_key = actions_state.select_key_to_edit_key
actions_state.select_key_to_edit_key = function(type) ---@diagnostic disable-line: duplicate-set-field
    local key = select_key_to_edit_key(type)
    return key == 'edit' and 'tabedit' or key
end
@powerman powerman added the enhancement Enhancement to performance, inner workings or existent features label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

No branches or pull requests

1 participant