mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
extract method to send data to a window
This commit is contained in:
@@ -133,7 +133,7 @@ export class Lifecycle {
|
||||
c(true); // veto
|
||||
});
|
||||
|
||||
vscodeWindow.win.webContents.send('vscode:beforeUnload', { okChannel: oneTimeOkEvent, cancelChannel: oneTimeCancelEvent });
|
||||
vscodeWindow.send('vscode:beforeUnload', { okChannel: oneTimeOkEvent, cancelChannel: oneTimeCancelEvent });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ export class VSCodeMenu {
|
||||
|
||||
// Resolve keybindings when workbench window is up
|
||||
if (this.actionIdKeybindingRequests.length) {
|
||||
win.win.webContents.send('vscode:resolveKeybindings', JSON.stringify(this.actionIdKeybindingRequests));
|
||||
win.send('vscode:resolveKeybindings', JSON.stringify(this.actionIdKeybindingRequests));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -294,9 +294,9 @@ export class VSCodeWindow {
|
||||
|
||||
// Support navigation via mouse buttons 4/5
|
||||
if (cmd === 'browser-backward') {
|
||||
this._win.webContents.send('vscode:runAction', 'workbench.action.navigateBack');
|
||||
this.send('vscode:runAction', 'workbench.action.navigateBack');
|
||||
} else if (cmd === 'browser-forward') {
|
||||
this._win.webContents.send('vscode:runAction', 'workbench.action.navigateForward');
|
||||
this.send('vscode:runAction', 'workbench.action.navigateForward');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -532,6 +532,16 @@ export class VSCodeWindow {
|
||||
this.win.setMenuBarVisibility(isFullScreen);
|
||||
}
|
||||
|
||||
public sendWhenReady(channel: string, ...args: any[]): void {
|
||||
this.ready().then(() => {
|
||||
this.send(channel, ...args);
|
||||
});
|
||||
}
|
||||
|
||||
public send(channel: string, ...args: any[]): void {
|
||||
this._win.webContents.send(channel, ...args);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this.showTimeoutHandle) {
|
||||
clearTimeout(this.showTimeoutHandle);
|
||||
|
||||
@@ -390,13 +390,13 @@ export class WindowsManager {
|
||||
if (!openFilesInNewWindow && lastActiveWindow) {
|
||||
lastActiveWindow.restore();
|
||||
lastActiveWindow.ready().then((readyWindow) => {
|
||||
readyWindow.win.webContents.send('vscode:openFiles', {
|
||||
readyWindow.send('vscode:openFiles', {
|
||||
filesToOpen: filesToOpen,
|
||||
filesToCreate: filesToCreate
|
||||
});
|
||||
|
||||
if (extensionsToInstall.length) {
|
||||
readyWindow.win.webContents.send('vscode:installExtensions', { extensionsToInstall });
|
||||
readyWindow.send('vscode:installExtensions', { extensionsToInstall });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -418,13 +418,13 @@ export class WindowsManager {
|
||||
if (windowsOnWorkspacePath.length > 0) {
|
||||
windowsOnWorkspacePath[0].restore(); // just focus one of them
|
||||
windowsOnWorkspacePath[0].ready().then((readyWindow) => {
|
||||
readyWindow.win.webContents.send('vscode:openFiles', {
|
||||
readyWindow.send('vscode:openFiles', {
|
||||
filesToOpen: filesToOpen,
|
||||
filesToCreate: filesToCreate
|
||||
});
|
||||
|
||||
if (extensionsToInstall.length) {
|
||||
readyWindow.win.webContents.send('vscode:installExtensions', { extensionsToInstall });
|
||||
readyWindow.send('vscode:installExtensions', { extensionsToInstall });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -889,9 +889,7 @@ export class WindowsManager {
|
||||
const focusedWindow = this.getFocusedWindow() || this.getLastActiveWindow();
|
||||
|
||||
if (focusedWindow) {
|
||||
focusedWindow.ready().then((readyWindow) => {
|
||||
readyWindow.win.webContents.send(channel, ...args);
|
||||
});
|
||||
focusedWindow.sendWhenReady(channel, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,9 +899,7 @@ export class WindowsManager {
|
||||
return; // do not send if we are instructed to ignore it
|
||||
}
|
||||
|
||||
w.ready().then((readyWindow) => {
|
||||
readyWindow.win.webContents.send(channel, payload);
|
||||
});
|
||||
w.sendWhenReady(channel, payload);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user