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 | var QuickViewService_1;
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.QuickViewService = void 0;
|
29 | const inversify_1 = require("inversify");
|
30 | const common_1 = require("../../common");
|
31 | const context_key_service_1 = require("../context-key-service");
|
32 | const quick_access_1 = require("./quick-access");
|
33 | const quick_input_service_1 = require("./quick-input-service");
|
34 | let QuickViewService = QuickViewService_1 = class QuickViewService {
|
35 | constructor() {
|
36 | this.items = [];
|
37 | this.hiddenItemLabels = new Set();
|
38 | }
|
39 | registerItem(item) {
|
40 | const quickOpenItem = {
|
41 | label: item.label,
|
42 | execute: () => item.open(),
|
43 | when: item.when
|
44 | };
|
45 | this.items.push(quickOpenItem);
|
46 | this.items.sort((a, b) => a.label.localeCompare(b.label));
|
47 | return common_1.Disposable.create(() => {
|
48 | const index = this.items.indexOf(quickOpenItem);
|
49 | if (index !== -1) {
|
50 | this.items.splice(index, 1);
|
51 | }
|
52 | });
|
53 | }
|
54 | hideItem(label) {
|
55 | this.hiddenItemLabels.add(label);
|
56 | }
|
57 | showItem(label) {
|
58 | this.hiddenItemLabels.delete(label);
|
59 | }
|
60 | registerQuickAccessProvider() {
|
61 | this.quickAccessRegistry.registerQuickAccessProvider({
|
62 | getInstance: () => this,
|
63 | prefix: QuickViewService_1.PREFIX,
|
64 | placeholder: '',
|
65 | helpEntries: [{ description: 'Open View', needsEditor: false }]
|
66 | });
|
67 | }
|
68 | getPicks(filter, token) {
|
69 | const items = this.items.filter(item => (item.when === undefined || this.contextKexService.match(item.when)) &&
|
70 | (!this.hiddenItemLabels.has(item.label)));
|
71 | return (0, quick_input_service_1.filterItems)(items, filter);
|
72 | }
|
73 | };
|
74 | QuickViewService.PREFIX = 'view ';
|
75 | __decorate([
|
76 | (0, inversify_1.inject)(quick_access_1.QuickAccessRegistry),
|
77 | __metadata("design:type", Object)
|
78 | ], QuickViewService.prototype, "quickAccessRegistry", void 0);
|
79 | __decorate([
|
80 | (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
|
81 | __metadata("design:type", Object)
|
82 | ], QuickViewService.prototype, "contextKexService", void 0);
|
83 | QuickViewService = QuickViewService_1 = __decorate([
|
84 | (0, inversify_1.injectable)()
|
85 | ], QuickViewService);
|
86 | exports.QuickViewService = QuickViewService;
|
87 |
|
\ | No newline at end of file |