-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add keyboard shortcut (ctrl/cmd-k) to clear console #1680
Conversation
Having some trouble figuring out what's going wrong with these tests. This is my first time trying to contribute to an open source project, so I'd greatly appreciate any guidance from those more experienced with this project. The changes I made appear to work when I try to run Fiddle (ctrl+k) does indeed clear the console, but I'm failing a CI test with the following error: |
Hi @knqu. The error in the unit tests is because we are using a Mock monaco solution in the tests, so when you use the Monaco API in the existing code, you need to add the same API in the Mock data. See: diff --git a/tests/mocks/monaco.ts b/tests/mocks/monaco.ts
index 0a5c9404..1cca8287 100644
--- a/tests/mocks/monaco.ts
+++ b/tests/mocks/monaco.ts
@@ -44,6 +44,12 @@ export class MonacoMock {
},
},
};
+ public KeyMod = {
+ CtrlCmd: jest.fn(),
+ };
+ public KeyCode = {
+ KEY_K: jest.fn(),
+ };
}
export class MonacoEditorMock {
@@ -55,6 +61,7 @@ export class MonacoEditorMock {
private model = new MonacoModelMock('', 'javascript');
private scrollHeight = 0;
+ public addCommand = jest.fn();
public dispose = jest.fn();
public getAction = jest.fn(() => this.action);
public getModel = jest.fn(() => this.model);
|
Thanks for the pointer @BlackHole1! I'll definitely keep that in mind going forward. |
@knqu could you please also add some logic to reset the console? From an abandoned PR: once that's done we can merge this. |
Hi @codebytere, thanks for getting back to me! That's a smart idea; I added it to my code. From my testing, the scroll logic seemed redundant, as clearing the console means there's nothing to scroll above, so I omitted that line. Please let me know if you have any other feedback! |
Fixes #1557
Add CTRL/CMD+k keyboard shortcut to clear the console.