Closed vandrieu closed 1 year ago
Hi @vandrieu! Thanks for taking the time to report this issue.
Ctrl+K is present in VS Code default keybindings only for MacOS (1). I guess that's why this issue hasn't been discovered and reported earlier.
I tried to reproduce the problem here on Windows by creating a similar keybinding definition for Ctrl-K:
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
}
...but for me this setup works as intended:
Since I don't have access to a Mac, I will need your help for checking out potential solutions. For starters, could you redefine shortcuts for Filter Lines with "when" like this (replace ctrl
with cmd
for MacOS):
{
"key": "ctrl+k ctrl+r",
"command": "-filterlines.includeLinesWithRegex"
},
{
"key": "ctrl+k ctrl+s",
"command": "-filterlines.includeLinesWithString"
},
{
"key": "ctrl+k ctrl+r",
"command": "filterlines.includeLinesWithRegex",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+k ctrl+s",
"command": "filterlines.includeLinesWithString",
"when": "editorTextFocus && !editorReadonly"
},
Does it solve the issue?
Also, are you using the default Ctrl-K keybinding (or maybe you defined your own)?
(1) The list of VS Code default keybindings can be seen here: https://github.com/codebling/vs-code-default-keybindings/
VS Code documentation is not helpful. It doesn't list Ctrl-K among default keybindings for MacOS:
I opened a VS Code issue because the fact that you defined a Ctrl+K Ctrl+R shortcut should not disable the Ctrl+K shortcut.
Moreover, changing the "Source" from "Default" to "User" changes the behavior which doesn't make sense.
Here is the issue, let's see if they find a bug in VS Code first: https://github.com/microsoft/vscode/issues/140226
And here is the demo video I provided them: https://youtu.be/u6WXsDoErmw
They did nothing about my issue... Do you plan changing your shortcut that interferes with the defaut VS Code "Clear Terminal" shortcut? If you keep the "Ctrl+K Ctrl+R" shortcut or anything that starts with "Ctrl+K" it means everybody using the Ctrl+K shortcut in their VS Code terminal to clear the terminal will have to stop using your extension (just like me and my colleagues had to do, we are not using your awesome extension anymore since january).
@vandrieu, hey! Sorry about that. Did you try disabling the default shortcuts (Ctrl-Shift-P > Preferences: Open Keyboard Shortcuts (JSON))?
{
"command": "-filterlines.includeLinesWithRegex",
"key": "ctrl-k ctrl-r",
"mac": "cmd-k cmd-r"
},
{
"command": "-filterlines.includeLinesWithString",
"key": "ctrl-k ctrl-s",
"mac": "cmd-k cmd-s"
}
Does it fix "Clear Terminal"?
Yes, I tried that, and it works, but for some reason that I can't explain, the cmd-k cmd-r shortcut just came back, like magically. I'll give it another try, I'll disable them right now and let you know if they reactivate for some reason.
Closing as working
When Filter Lines is installed, we can't clear the terminal using Ctrl+K anymore.
Deleting bindings solves the problem, but I'm sure there are a lot of Filter Lines users out there having trouble clearing their terminals and who have no idea it's related to Filter Lines and making their experience of VS Code a lot more frustrating, so it would be nice to fix this problem.
Demo: https://youtu.be/450R0qbPzR8