1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.WindowTitleUpdater = void 0;
|
19 | const tslib_1 = require("tslib");
|
20 | const navigatable_types_1 = require("../navigatable-types");
|
21 | const inversify_1 = require("inversify");
|
22 | const window_title_service_1 = require("./window-title-service");
|
23 | const label_provider_1 = require("../label-provider");
|
24 | const saveable_1 = require("../saveable");
|
25 | const common_1 = require("../../common");
|
26 | let WindowTitleUpdater = class WindowTitleUpdater {
|
27 | constructor() {
|
28 | this.toDisposeOnWidgetChanged = common_1.Disposable.NULL;
|
29 | }
|
30 | onStart(app) {
|
31 | app.shell.mainPanel.onDidChangeCurrent(title => this.handleWidgetChange(title === null || title === void 0 ? void 0 : title.owner));
|
32 | this.handleWidgetChange(app.shell.getCurrentWidget('main'));
|
33 | }
|
34 | handleWidgetChange(widget) {
|
35 | this.toDisposeOnWidgetChanged.dispose();
|
36 | const saveable = saveable_1.Saveable.get(widget);
|
37 | if (saveable) {
|
38 | this.toDisposeOnWidgetChanged = saveable.onDirtyChanged(() => this.windowTitleService.update({ dirty: saveable.dirty ? '●' : '' }));
|
39 | }
|
40 | else {
|
41 | this.toDisposeOnWidgetChanged = common_1.Disposable.NULL;
|
42 | }
|
43 | this.updateTitleWidget(widget);
|
44 | }
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 | updateTitleWidget(widget) {
|
51 | let activeEditorLong;
|
52 | let activeEditorMedium;
|
53 | let activeEditorShort;
|
54 | let activeFolderLong;
|
55 | let activeFolderMedium;
|
56 | let activeFolderShort;
|
57 | let dirty;
|
58 | const uri = navigatable_types_1.NavigatableWidget.getUri(widget);
|
59 | if (uri) {
|
60 | activeEditorLong = uri.path.fsPath();
|
61 | activeEditorMedium = this.labelProvider.getLongName(uri);
|
62 | activeEditorShort = this.labelProvider.getName(uri);
|
63 | const parent = uri.parent;
|
64 | activeFolderLong = parent.path.fsPath();
|
65 | activeFolderMedium = this.labelProvider.getLongName(parent);
|
66 | activeFolderShort = this.labelProvider.getName(parent);
|
67 | }
|
68 | else if (widget) {
|
69 | const widgetTitle = widget.title.label;
|
70 | activeEditorLong = widgetTitle;
|
71 | activeEditorMedium = widgetTitle;
|
72 | activeEditorShort = widgetTitle;
|
73 | }
|
74 | if (saveable_1.Saveable.isDirty(widget)) {
|
75 | dirty = '●';
|
76 | }
|
77 | this.windowTitleService.update({
|
78 | activeEditorLong,
|
79 | activeEditorMedium,
|
80 | activeEditorShort,
|
81 | activeFolderLong,
|
82 | activeFolderMedium,
|
83 | activeFolderShort,
|
84 | dirty
|
85 | });
|
86 | }
|
87 | };
|
88 | (0, tslib_1.__decorate)([
|
89 | (0, inversify_1.inject)(window_title_service_1.WindowTitleService),
|
90 | (0, tslib_1.__metadata)("design:type", window_title_service_1.WindowTitleService)
|
91 | ], WindowTitleUpdater.prototype, "windowTitleService", void 0);
|
92 | (0, tslib_1.__decorate)([
|
93 | (0, inversify_1.inject)(label_provider_1.LabelProvider),
|
94 | (0, tslib_1.__metadata)("design:type", label_provider_1.LabelProvider)
|
95 | ], WindowTitleUpdater.prototype, "labelProvider", void 0);
|
96 | WindowTitleUpdater = (0, tslib_1.__decorate)([
|
97 | (0, inversify_1.injectable)()
|
98 | ], WindowTitleUpdater);
|
99 | exports.WindowTitleUpdater = WindowTitleUpdater;
|
100 |
|
\ | No newline at end of file |