无法修改VSCode中搜索输入框中与光标相关命令的键绑定。

huangapple go评论60阅读模式
英文:

Unable to modify keybinding for cursor related commands of search input box in VSCode

问题

我尝试修改VSCode中的键绑定,在尝试修改搜索输入框的光标相关命令时遇到了问题。以下键绑定 ctrl+b 在焦点在编辑器文本中时可以正常工作,并且光标会如预期地向左移动。

{
    "key": "ctrl+b",
    "command": "cursorLeft",
    "when": "editorTextFocus || searchInputBoxFocus || inSearchEditor || searchViewletFocus"
}

然而,当光标位于搜索输入框中时,键绑定没有任何效果,我仍然需要按左箭头键。

无法修改VSCode中搜索输入框中与光标相关命令的键绑定。

是否有其他命令或特定的条件可以在搜索输入框中移动光标?

第一个评论的附加信息:

在键盘快捷键故障排除中,当我在文本编辑器中按下左箭头键时,光标向左移动,我得到以下输出,表明调用了 cursorLeft 命令:

[KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowLeft, keyCode: 37, key: ArrowLeft
[KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowLeft, keyCode: 15 ('LeftArrow')
[KeybindingService]: | Resolving [ArrowLeft]
[KeybindingService]: \ From 10 keybinding entries, matched cursorLeft, when: textInputFocus, source: built-in.
[KeybindingService]: + Invoking command cursorLeft.

在键盘快捷键故障排除中,当我在搜索输入框中按下左箭头键时,光标向左移动,并且我得到以下输出,但没有显示任何关联的命令名称:

[KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowLeft, keyCode: 37, key: ArrowLeft
[KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowLeft, keyCode: 15 ('LeftArrow')
[KeybindingService]: | Resolving [ArrowLeft]
[KeybindingService]: \ From 9 keybinding entries, no when clauses matched the context.
英文:

I try to modify keybindings in VSCode and came across a problem when I try to modify cursor related commands for search input box. Following keybinding ctrl+b works well when focus is in the editor text and cursor moves to left as expected.

{
    "key": "ctrl+b",
    "command": "cursorLeft",
    "when": "editorTextFocus || searchInputBoxFocus || inSearchEditor || searchViewletFocus"
},

However when the cursor is in the search input box, keybinding doesn't have any effect, I still have to press left arrow key.

无法修改VSCode中搜索输入框中与光标相关命令的键绑定。

Are there any other command or specific when condition to move cursor in search input box?

Additional information for first comment:

In keyboard shortcuts troubleshooting when I press left arrow key in text editor, cursor moves left and I get following output which tells cursorLeft command is invoked:

[KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowLeft, keyCode: 37, key: ArrowLeft
[KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowLeft, keyCode: 15 ('LeftArrow')
[KeybindingService]: | Resolving [ArrowLeft]
[KeybindingService]: \ From 10 keybinding entries, matched cursorLeft, when: textInputFocus, source: built-in.
[KeybindingService]: + Invoking command cursorLeft.

In keyboard shortcuts troubleshooting when I press left arrow key in search input box, cursor moves left and I get following output, which does not give any associated command name:

[KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowLeft, keyCode: 37, key: ArrowLeft
[KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowLeft, keyCode: 15 ('LeftArrow')
[KeybindingService]: | Resolving [ArrowLeft]
[KeybindingService]: \ From 9 keybinding entries, no when clauses matched the context.

答案1

得分: 0

我认为你有这个问题:Keybindings don't respect editorTextFocus in the find widget

看起来一些基本命令已经硬编码(至少对于查找小部件而言,但这可能也适用于搜索输入),因此无法由用户修改:

> 我认为我最初添加了这段代码,可能超过10年了 :).
> 转交给你考虑。这里的请求是从 findWidget.ts 中删除硬编码的键绑定,并创建一个带有键绑定 ctrl+down 的命令。
> 这将允许用户重新绑定 ctrl+down 的行为。

还可以更一般地查看,包括搜索输入 Allow to configure cursor keys for input fields

因此,VSCode团队已经意识到了这个问题,并且已经在待办事项列表中 - 在此期间,你可以投票支持这些问题。

英文:

I think you have this issue: Keybindings don't respect editorTextFocus in the find widget.

It looks like some basic commands were hard-coded (at least for the FInd Widget but that probably applies to the Search Inputs as well) and so can't be modified by a user:

> I think I added that code initially, maybe more than 10 years ago :).
> Forwarding to you for your consideration. The ask here is to remove
> the hard-coded keybinding from findWidget.ts and create a command
> which would have the keybinding ctrl+down. That would allow users to
> rebind the behavior of ctrl+down.

Also see more generally, including search input Allow to configure cursor keys for input fields.

So the vscode team is aware of the issue and it is on the backlog - you could upvote those issues in the meantime.

huangapple
  • 本文由 发表于 2023年6月5日 23:32:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76407943.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定