Force a redraw of terminal after OS resumes

Part of #58167
pull/65822/head
Daniel Imms 2018-12-28 15:26:06 -08:00
parent a681de42d1
commit 1c7194ad5d
4 changed files with 19 additions and 1 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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;

View File

@ -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 {