mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 08:10:11 +01:00
Merge pull request #3900 from microsoft/hediet/b/moral-scorpion
Adds reload action (Ctrl+Enter)
This commit is contained in:
commit
8983c59033
1 changed files with 19 additions and 2 deletions
|
|
@ -148,6 +148,17 @@ export class PlaygroundModel {
|
|||
constructor() {
|
||||
let lastState = this.state;
|
||||
|
||||
this.dispose.track(
|
||||
monaco.editor.addEditorAction({
|
||||
id: "reload",
|
||||
label: "Reload",
|
||||
run: (editor, ...args) => {
|
||||
this.reload();
|
||||
},
|
||||
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
|
||||
})
|
||||
);
|
||||
|
||||
this.dispose.track({
|
||||
dispose: reaction(
|
||||
() => ({ state: this.state }),
|
||||
|
|
@ -162,13 +173,19 @@ export class PlaygroundModel {
|
|||
return;
|
||||
}
|
||||
}
|
||||
this.debouncer.run(() => {
|
||||
const action = () => {
|
||||
this.isDirty = false;
|
||||
lastState = state;
|
||||
for (const handler of this._previewHandlers) {
|
||||
handler.handlePreview(state);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (state.key !== lastState.key) {
|
||||
action(); // sync update
|
||||
} else {
|
||||
this.debouncer.run(action);
|
||||
}
|
||||
},
|
||||
{ name: "update preview" }
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue