vscode workbench.action.toggleSidebarVisibility 忘记选择的文件

z18hc3ub  于 5个月前  发布在  Vscode
关注(0)|答案(7)|浏览(74)

尝试使用以下代码切换侧边栏:

{
        "key": "ctrl+\\",
        "command": "workbench.files.action.focusFilesExplorer",
        // "command": "workbench.explorer.fileView.focus",
        "when": "!explorerViewletVisible"
    },
    {
        "key": "ctrl+\\",
        "command": "workbench.action.toggleSidebarVisibility",
        // "command": "workbench.action.closeSidebar",
        "when": "sideBarVisible"
    },

但是在不可见的侧边栏 workbench.files.action.focusFilesExplorer 上,它只会聚焦整个列表,而在可见的侧边栏上,它会聚焦列表中的最后一个选定项。

xriantvc

xriantvc1#

你能在这里进行基本的故障排除吗?https://github.com/microsoft/vscode/wiki/Keybinding-Issues,并在侧边栏不可见时发布哪个命令正在执行。我想知道命令是否正确执行。

6ie5vjzr

6ie5vjzr2#

2023-04-11 20:13:52.313 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 17, key: Control
2023-04-11 20:13:52.313 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 5 ('Ctrl')
2023-04-11 20:13:52.314 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2023-04-11 20:13:52.672 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-04-11 20:13:52.672 [info] [KeybindingService]: | Resolving ctrl+\
2023-04-11 20:13:52.672 [info] [KeybindingService]: \ From 3 keybinding entries, matched workbench.action.toggleSidebarVisibility, when: sideBarVisible, source: user.
2023-04-11 20:13:52.672 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl], code: Backslash, keyCode: 220, key: \
2023-04-11 20:13:52.673 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl], code: Backslash, keyCode: 88 ('\')
2023-04-11 20:13:52.673 [info] [KeybindingService]: | Resolving ctrl+\
2023-04-11 20:13:52.673 [info] [KeybindingService]: \ From 3 keybinding entries, matched workbench.action.toggleSidebarVisibility, when: sideBarVisible, source: user.
2023-04-11 20:13:52.674 [info] [KeybindingService]: + Invoking command workbench.action.toggleSidebarVisibility.
2023-04-11 20:13:54.022 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl], code: Backslash, keyCode: 220, key: \
2023-04-11 20:13:54.023 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl], code: Backslash, keyCode: 88 ('\')
2023-04-11 20:13:54.023 [info] [KeybindingService]: | Resolving ctrl+\
2023-04-11 20:13:54.024 [info] [KeybindingService]: \ From 3 keybinding entries, matched workbench.files.action.focusFilesExplorer, when: !explorerViewletVisible, source: user.
2023-04-11 20:13:54.024 [info] [KeybindingService]: + Invoking command workbench.files.action.focusFilesExplorer.
q5lcpyga

q5lcpyga3#

以下是您提供的文本内容的翻译结果:


一些额外信息:
设置:

{
"keyboard.dispatch": "keyCode",
}


无虚拟化
环境:

OS: Gentoo 2.13
Kernel: x86_64 Linux 5.10.76-gentoo-r1
WM: i3
Code:
1.76.2
ee2b180d582a7f601fa6ecfdad8d9fd269ab1884
x64


setxkbmap -query

rules: evdev
model: pc105
layout: us,ru
options: grp:caps_toggle,grp_led:caps

stszievb

stszievb4#

截图:
问题:
打开时具有焦点:

切换侧边栏然后再次打开:

预期结果:
不活动但可见的侧边栏:

File: Focus on Files Explorer 恢复焦点:

yvgpqqbh

yvgpqqbh5#

尝试使用 workbench.files.action.showActiveFileInExplorer 作为你的命令代替

bn31dyow

bn31dyow6#

已经存在这样的快捷键

{
        "key": "ctrl+shift+\\",
        "command": "workbench.files.action.showActiveFileInExplorer",
    },

但是它会将光标移动到当前打开的文件,并且只有在文件资源管理器可见时才会这样做。对于不可见的文件资源管理器,它只会打开文件资源管理器而不显示活动文件,而且只有在打开的文件属于文件树时才会这样做。
此外还尝试了 workbench.explorer.fileView.focus 代替 workbench.files.action.focusFilesExplorer 。它们的行为相同

pkbketx9

pkbketx97#

对于不可见的文件资源管理器,只需打开文件资源管理器而不显示活动文件,并且仅当打开的文件属于文件树时才这样做。
是的,它必须位于文件树中,但是当我将侧边栏最小化时,这个命令对我来说确实可以打开并聚焦文件。然而,您说得对,如果树被隐藏然后揭示,选择就会丢失。这并非所有树的情况,所以我会将其标记为一个错误。

相关问题