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