vscode如何添加键盘快捷方式以暂存所选行

elf*_*ong 8 visual-studio-code

Stage Selected Linesgit 有一个按钮,但有没有办法为它添加键盘快捷键? 在此输入图像描述

点击两次(three dots> Stage Selected Lines)太麻烦了.

Mar*_*lug 7

如果有人还在寻找这个:

之前已经引入了命令stageSelectedRanges,unstageSelectedRanges,revertSelectedRanges.需要注意的是,目前在VSCode相关的错误:在差异视图中的部分阶段之后不刷新(https://github.com/Microsoft/vscode/issues/26642) -但它的工作原理就像一个魅力分开.

这是我在我的键绑定中设置它的方式:

{
  "key": "s",
  "command": "git.stageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "u",
  "command": "git.unstageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "r",
  "command": "git.revertSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
}
Run Code Online (Sandbox Code Playgroud)


rnd*_*are 6

接受的答案对我不起作用,所以我提出了一张票:

https://github.com/microsoft/vscode/issues/99683

做了以下事情:

{
    "key": "ctrl+a",
    "command": "git.stageAll",
    "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
    "key": "ctrl+s",
    "command": "git.stage",
    "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
    "key": "ctrl+u",
    "command": "git.unstage",
    "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
Run Code Online (Sandbox Code Playgroud)

更新:

我还能够通过添加 listFocus 属性使单个键工作:

{
  "key": "s",
  "command": "git.stage",
  "when": "listFocus && sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
Run Code Online (Sandbox Code Playgroud)