fix(file-manager): open the selection with Enter instead of changing directory

Enter quit the panel and cd'ed the shell, which silently did nothing when the
panel ran in a dock, where there is no shell to move. Enter now behaves like
the right arrow and descends into a directory in place, while Ctrl+Enter keeps
the shell directory change and no longer depends on the selection.
This commit is contained in:
BlackAngelTV committed 2026-11-09 12:24:06 +01:00
1 parent a8129b1d5d
commit 38afa54ad9
4 files changed
+33 -30

No files matched your search

+6 -6
View File
@@ -395,20 +395,20 @@ func (h *Handler) copy_selected_path() {
h.draw_screen()
}
// activate implements the primary action: the selected directory becomes the
// working directory of the shell, the selected file is opened in the editor.
// activate implements the primary action: the selected directory is opened in
// the panel, the selected file is opened in the editor. Enter used to quit the
// panel and cd the shell, which did nothing when the panel was docked.
func (h *Handler) activate() {
e, ok := h.selected_entry()
if !ok {
h.lp.Beep()
return
}
path := entry_path(h.cwd, e.Name)
if e.IsDir {
h.change_shell_dir_to(path)
h.enter_dir()
return
}
h.open_file(path)
h.open_file(entry_path(h.cwd, e.Name))
}
// edit_args is the client side of kitty's edit protocol. The terminal opens the
@@ -766,7 +766,7 @@ func (h *Handler) draw_screen() {
h.lp.QueueWriteString(h.lp.SprintStyled("bold fg=bright-red", fmt.Sprintf("Delete %s? [y/N] ", h.confirm_name)))
default:
h.lp.SetCursorVisible(false)
hints := "Enter: cd/open ->: enter <-: up .: hidden n: new file r: rename d: delete y: copy q: quit"
hints := "Enter: open ->: enter Ctrl+Enter: cd here <-: up .: hidden n: new file r: rename d: delete y: copy q: quit"
h.lp.QueueWriteString(h.lp.SprintStyled("dim", truncate_to_width(hints, width)))
}
}
+8 -7
View File
@@ -90,14 +90,15 @@ map('Select first entry', 'home --allow-fallback=shifted,ascii g home')
map('Select last entry', 'end end end')
map('Select last entry', 'end shift+g end')
map(
'Change shell directory or open selection',
'Open the selection',
'activate enter activate',
long_text="""
When the selection is a directory it becomes the working directory of the shell
that launched the panel. When it is a file, the panel opens it in kitty's editor
(:opt:`editor`, :envvar:`VISUAL` or :envvar:`EDITOR`) in a new tab, and is
drawn again with the same selection once the editor exits. The new tab is what
gives the file a whole window even when the panel runs in a dock.
When the selection is a directory it is opened in the panel, exactly like the
:ref:`enter_dir <file-manager-shortcuts>` shortcut. When it is a file, the panel
opens it in kitty's editor (:opt:`editor`, :envvar:`VISUAL` or
:envvar:`EDITOR`) in a new tab, and is drawn again with the same selection once
the editor exits. The new tab is what gives the file a whole window even when
the panel runs in a dock.
""",
)
map(
@@ -105,7 +106,7 @@ map(
'enter_dir right enter_dir',
long_text="""
Move the panel into the selected directory without changing the shell's working
directory. Use the :ref:`activate <file-manager-shortcuts>` shortcut to also
directory. Use the :ref:`cd_here <file-manager-shortcuts>` shortcut to also
change the shell's directory.
""",
)