|
6 | 6 | import * as path from 'vs/base/common/path'; |
7 | 7 | import * as objects from 'vs/base/common/objects'; |
8 | 8 | import * as nls from 'vs/nls'; |
9 | | -import { Event as CommonEvent, Emitter } from 'vs/base/common/event'; |
| 9 | +import { Emitter } from 'vs/base/common/event'; |
10 | 10 | import { URI } from 'vs/base/common/uri'; |
11 | 11 | import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme } from 'electron'; |
12 | 12 | import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; |
@@ -69,21 +69,23 @@ export class CodeWindow extends Disposable implements ICodeWindow { |
69 | 69 | private static readonly MAX_URL_LENGTH = 2 * 1024 * 1024; // https://cs.chromium.org/chromium/src/url/url_constants.cc?l=32 |
70 | 70 |
|
71 | 71 | private readonly _onClose = this._register(new Emitter<void>()); |
72 | | - readonly onClose: CommonEvent<void> = this._onClose.event; |
| 72 | + readonly onClose = this._onClose.event; |
73 | 73 |
|
74 | 74 | private readonly _onDestroy = this._register(new Emitter<void>()); |
75 | | - readonly onDestroy: CommonEvent<void> = this._onDestroy.event; |
| 75 | + readonly onDestroy = this._onDestroy.event; |
76 | 76 |
|
77 | 77 | private readonly _onLoad = this._register(new Emitter<void>()); |
78 | | - readonly onLoad: CommonEvent<void> = this._onLoad.event; |
| 78 | + readonly onLoad = this._onLoad.event; |
79 | 79 |
|
80 | 80 | private hiddenTitleBarStyle: boolean | undefined; |
81 | 81 | private showTimeoutHandle: NodeJS.Timeout | undefined; |
82 | 82 | private _lastFocusTime: number; |
83 | 83 | private _readyState: ReadyState; |
84 | 84 | private windowState: IWindowState; |
85 | 85 | private currentMenuBarVisibility: MenuBarVisibility | undefined; |
| 86 | + |
86 | 87 | private representedFilename: string | undefined; |
| 88 | + private documentEdited: boolean | undefined; |
87 | 89 |
|
88 | 90 | private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[]; |
89 | 91 |
|
@@ -271,6 +273,22 @@ export class CodeWindow extends Disposable implements ICodeWindow { |
271 | 273 | return this.representedFilename; |
272 | 274 | } |
273 | 275 |
|
| 276 | + setDocumentEdited(edited: boolean): void { |
| 277 | + if (isMacintosh) { |
| 278 | + this._win.setDocumentEdited(edited); |
| 279 | + } |
| 280 | + |
| 281 | + this.documentEdited = edited; |
| 282 | + } |
| 283 | + |
| 284 | + isDocumentEdited(): boolean { |
| 285 | + if (isMacintosh) { |
| 286 | + return this._win.isDocumentEdited(); |
| 287 | + } |
| 288 | + |
| 289 | + return !!this.documentEdited; |
| 290 | + } |
| 291 | + |
274 | 292 | focus(): void { |
275 | 293 | if (!this._win) { |
276 | 294 | return; |
@@ -586,9 +604,9 @@ export class CodeWindow extends Disposable implements ICodeWindow { |
586 | 604 | } |
587 | 605 |
|
588 | 606 | // Clear Document Edited if needed |
589 | | - if (isMacintosh && this._win.isDocumentEdited()) { |
| 607 | + if (this.isDocumentEdited()) { |
590 | 608 | if (!isReload || !this.backupMainService.isHotExitEnabled()) { |
591 | | - this._win.setDocumentEdited(false); |
| 609 | + this.setDocumentEdited(false); |
592 | 610 | } |
593 | 611 | } |
594 | 612 |
|
|
0 commit comments