From 1c7194ad5d3b07faddf1297a8e332bf406213c96 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 28 Dec 2018 15:26:06 -0800 Subject: [PATCH] Force a redraw of terminal after OS resumes Part of #58167 --- src/vs/code/electron-main/app.ts | 8 +++++++- src/vs/workbench/parts/terminal/common/terminal.ts | 5 +++++ .../parts/terminal/electron-browser/terminalInstance.ts | 4 ++++ .../parts/terminal/electron-browser/terminalService.ts | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index ef2349e6b59..a496a5505be 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol } from 'electron'; +import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor } from 'electron'; import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform'; import { WindowsManager } from 'vs/code/electron-main/windows'; import { IWindowsService, OpenContext, ActiveWindowManager } from 'vs/platform/windows/common/windows'; @@ -260,6 +260,12 @@ export class CodeApplication extends Disposable { ipc.on('vscode:openDevTools', (event: Event) => event.sender.openDevTools()); ipc.on('vscode:reloadWindow', (event: Event) => event.sender.reload()); + + powerMonitor.on('resume', () => { // After waking up from sleep + if (this.windowsMainService) { + this.windowsMainService.sendToAll('vscode:osResume', undefined); + } + }); } private onUnexpectedError(err: Error): void { diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index a6b71721655..acd483519bf 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -427,6 +427,11 @@ export interface ITerminalInstance { */ dispose(immediate?: boolean): void; + /** + * Forces the terminal to redraw its viewport. + */ + forceRedraw(): void; + /** * Registers a link matcher, allowing custom link patterns to be matched and handled. * @param regex The regular expression the search for, specifically this searches the diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index e1f81f7b804..1ecfde7af35 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -620,6 +620,10 @@ export class TerminalInstance implements ITerminalInstance { this._disposables = lifecycle.dispose(this._disposables); } + public forceRedraw(): void { + this._xterm.refresh(0, this._xterm.rows - 1); + } + public focus(force?: boolean): void { if (!this._xterm) { return; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index 254251f7652..1cde5cc9375 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -69,6 +69,9 @@ export class TerminalService extends AbstractTerminalService implements ITermina }); } }); + ipc.on('vscode:osResume', () => { + this.getActiveTab().terminalInstances.forEach(instance => instance.forceRedraw()); + }); } public createTerminal(shell: IShellLaunchConfig = {}, wasNewTerminalAction?: boolean): ITerminalInstance {