Skip to content

Commit dbdfa73

Browse files
authored
feat: add keyboard shortcut (ctrl/cmd-k) to clear console (#1680)
* feat: add keyboard shortcut (ctrl/cmd-k) to clear console * feat: update monaco mock * feat: reset console on clear
1 parent 06625d2 commit dbdfa73

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/renderer/components/output.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ export const Output = observer(
9191
openerService: this.openerService(),
9292
},
9393
);
94+
95+
this.editor.addCommand(
96+
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K,
97+
() => {
98+
this.props.appState.clearConsole();
99+
this.props.appState.output.push({
100+
timeString: new Date().toLocaleTimeString(),
101+
text: '',
102+
});
103+
},
104+
);
94105
}
95106
}
96107

tests/mocks/monaco.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export class MonacoMock {
4444
},
4545
},
4646
};
47+
public KeyMod = {
48+
CtrlCmd: jest.fn(),
49+
};
50+
public KeyCode = {
51+
KEY_K: jest.fn(),
52+
};
4753
}
4854

4955
export class MonacoEditorMock {
@@ -55,6 +61,7 @@ export class MonacoEditorMock {
5561
private model = new MonacoModelMock('', 'javascript');
5662
private scrollHeight = 0;
5763

64+
public addCommand = jest.fn();
5865
public dispose = jest.fn();
5966
public getAction = jest.fn(() => this.action);
6067
public getModel = jest.fn(() => this.model);

0 commit comments

Comments
 (0)