microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.63k stars 29.04k forks source link

Cmd+k in the integrated terminal does not clear the text #35685

Closed svenax closed 7 years ago

svenax commented 7 years ago
Extension Author (truncated) Version
swagger-viewer Arj 1.4.0
vscode-generate-getter-setter DSK 0.4.2
xml Dot 1.9.2
vscode-pandoc Dou 0.0.8
EditorConfig Edi 0.10.1
latex-workshop Jam 3.5.5
vscode-docker Pet 0.0.18
latex-preview ajs 0.5.1
vscode-intelephense-client bme 0.7.2
vscode-eslint dba 1.3.2
githistory don 0.2.3
gitlens eam 5.4.1
tslint eg2 1.0.9
git-project-manager fel 1.4.0
php-debug fel 1.11.1
php-intellisense fel 1.5.1
php-pack fel 1.0.1
auto-rename-tag for 0.0.14
ruby gro 0.0.6
phpcs ika 0.7.0
codeacejumper luc 1.1.5
Go luk 0.6.66
ruby-symbols mig 0.1.5
vscode-clang mit 0.2.2
cpptools ms- 0.13.1
php-docblocker nei 1.3.0
advanced-new-file pat 0.5.0
java red 0.11.0
vscode-table-formatter shu 1.2.1
vscode-hexdump sle 1.4.0
Align ste 0.2.0
rewrap stk 1.5.1
gotimeformat v4r 1.0.1
vscode-todo-highlight way 0.5.11

In an external terminal window, typing cmd+K clears all text. The default keyboard shortcuts contain the following, indicating that this should work in the integrated terminal too:

{ "key": "cmd+k",                 "command": "workbench.action.terminal.clear",
                                     "when": "terminalFocus" },

Steps to Reproduce:

  1. In the Terminal pane, type cmd+K to clear the text.
  2. Instead of clearing, the status line displays "Waiting for second key of chord".

Reproduces without extensions: Yes

Tyriar commented 7 years ago

Works for me, do you have any custom keybindings?

svenax commented 7 years ago

I do have custom bindings with a cmd+k prefix. It works if I remove those, so apparently builtin and custom bindings are handled differently. Here are the relevant bindings:

    {
        "key": "cmd+k w",
        "command": "editor.action.toggleWordWrap"
    },
    { 
        "key": "cmd+k f",               
        "command": "-workbench.action.closeFolder" 
    },
    {
        "key": "cmd+k f",
        "command": "editor.action.formatDocument",
        "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
    },
Tyriar commented 7 years ago

@svenax overriding a coord keybinding is a little fragile, you will notice in the default keybindings that cmd+k is below all the other chord keybindings (except for markdown preview which has a different context). This is intentional and is how they're overridden when the terminal is focused.

The current way around this is to just redefine cmd+k again underneath your custom keybindings:

    {
        "key": "cmd+k w",
        "command": "editor.action.toggleWordWrap"
    },
    { 
        "key": "cmd+k f",               
        "command": "-workbench.action.closeFolder" 
    },
    {
        "key": "cmd+k f",
        "command": "editor.action.formatDocument",
        "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
    },
{ "key": "cmd+k",                 "command": "workbench.action.terminal.clear",
                                     "when": "terminalFocus" },