window picker - indicate dirty windows

This commit is contained in:
Benjamin Pasero
2020-03-30 08:58:36 +02:00
parent 13b38d2a49
commit 9556196ed6
8 changed files with 53 additions and 22 deletions

View File

@@ -6,7 +6,7 @@
import * as path from 'vs/base/common/path';
import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
import { Emitter } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme } from 'electron';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
@@ -69,13 +69,13 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private static readonly MAX_URL_LENGTH = 2 * 1024 * 1024; // https://cs.chromium.org/chromium/src/url/url_constants.cc?l=32
private readonly _onClose = this._register(new Emitter<void>());
readonly onClose: CommonEvent<void> = this._onClose.event;
readonly onClose = this._onClose.event;
private readonly _onDestroy = this._register(new Emitter<void>());
readonly onDestroy: CommonEvent<void> = this._onDestroy.event;
readonly onDestroy = this._onDestroy.event;
private readonly _onLoad = this._register(new Emitter<void>());
readonly onLoad: CommonEvent<void> = this._onLoad.event;
readonly onLoad = this._onLoad.event;
private hiddenTitleBarStyle: boolean | undefined;
private showTimeoutHandle: NodeJS.Timeout | undefined;
@@ -83,7 +83,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private _readyState: ReadyState;
private windowState: IWindowState;
private currentMenuBarVisibility: MenuBarVisibility | undefined;
private representedFilename: string | undefined;
private documentEdited: boolean | undefined;
private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[];
@@ -271,6 +273,22 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return this.representedFilename;
}
setDocumentEdited(edited: boolean): void {
if (isMacintosh) {
this._win.setDocumentEdited(edited);
}
this.documentEdited = edited;
}
isDocumentEdited(): boolean {
if (isMacintosh) {
return this._win.isDocumentEdited();
}
return !!this.documentEdited;
}
focus(): void {
if (!this._win) {
return;
@@ -586,9 +604,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
// Clear Document Edited if needed
if (isMacintosh && this._win.isDocumentEdited()) {
if (this.isDocumentEdited()) {
if (!isReload || !this.backupMainService.isHotExitEnabled()) {
this._win.setDocumentEdited(false);
this.setDocumentEdited(false);
}
}