@codingame/monaco-vscode-scm-service-override 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,174 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/scm.css.js';
3
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
4
+ import { Event } from 'vscode/vscode/vs/base/common/event';
5
+ import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
6
+ import { append, $ } from 'vscode/vscode/vs/base/browser/dom';
7
+ import { ISCMViewService } from 'vscode/vscode/vs/workbench/contrib/scm/common/scm';
8
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
10
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
11
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
12
+ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
13
+ import { WorkbenchList } from 'vscode/vscode/vs/platform/list/browser/listService';
14
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
15
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
16
+ import { SIDE_BAR_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
17
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
18
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
19
+ import { RepositoryRenderer, RepositoryActionRunner } from './scmRepositoryRenderer.js';
20
+ import { getActionViewItemProvider, collectContextMenuActions } from './util.js';
21
+ import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
22
+ import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
23
+ import { MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
24
+
25
+ class ListDelegate {
26
+ getHeight() {
27
+ return 22;
28
+ }
29
+ getTemplateId() {
30
+ return RepositoryRenderer.TEMPLATE_ID;
31
+ }
32
+ }
33
+ let SCMRepositoriesViewPane = class SCMRepositoriesViewPane extends ViewPane {
34
+ constructor(options, scmViewService, keybindingService, contextMenuService, instantiationService, viewDescriptorService, contextKeyService, configurationService, openerService, themeService, telemetryService) {
35
+ super({ ...options, titleMenuId: MenuId.SCMSourceControlTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
36
+ this.scmViewService = scmViewService;
37
+ this.disposables = ( new DisposableStore());
38
+ }
39
+ renderBody(container) {
40
+ super.renderBody(container);
41
+ const listContainer = append(container, $('.scm-view.scm-repositories-view'));
42
+ const updateProviderCountVisibility = () => {
43
+ const value = this.configurationService.getValue('scm.providerCountBadge');
44
+ listContainer.classList.toggle('hide-provider-counts', value === 'hidden');
45
+ listContainer.classList.toggle('auto-provider-counts', value === 'auto');
46
+ };
47
+ this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.providerCountBadge'), this.disposables)(updateProviderCountVisibility));
48
+ updateProviderCountVisibility();
49
+ const delegate = ( new ListDelegate());
50
+ const renderer = this.instantiationService.createInstance(RepositoryRenderer, MenuId.SCMSourceControlInline, getActionViewItemProvider(this.instantiationService));
51
+ const identityProvider = { getId: (r) => r.provider.id };
52
+ this.list = this.instantiationService.createInstance(WorkbenchList, `SCM Main`, listContainer, delegate, [renderer], {
53
+ identityProvider,
54
+ horizontalScrolling: false,
55
+ overrideStyles: {
56
+ listBackground: SIDE_BAR_BACKGROUND
57
+ },
58
+ accessibilityProvider: {
59
+ getAriaLabel(r) {
60
+ return r.provider.label;
61
+ },
62
+ getWidgetAriaLabel() {
63
+ return ( localizeWithPath(
64
+ 'vs/workbench/contrib/scm/browser/scmRepositoriesViewPane',
65
+ 'scm',
66
+ "Source Control Repositories"
67
+ ));
68
+ }
69
+ }
70
+ });
71
+ this._register(this.list);
72
+ this._register(this.list.onDidChangeSelection(this.onListSelectionChange, this));
73
+ this._register(this.list.onContextMenu(this.onListContextMenu, this));
74
+ this._register(this.scmViewService.onDidChangeRepositories(this.onDidChangeRepositories, this));
75
+ this._register(this.scmViewService.onDidChangeVisibleRepositories(this.updateListSelection, this));
76
+ if (this.orientation === 0 ) {
77
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
78
+ if (e.affectsConfiguration('scm.repositories.visible')) {
79
+ this.updateBodySize();
80
+ }
81
+ }));
82
+ }
83
+ this.onDidChangeRepositories();
84
+ this.updateListSelection();
85
+ }
86
+ onDidChangeRepositories() {
87
+ this.list.splice(0, this.list.length, this.scmViewService.repositories);
88
+ this.updateBodySize();
89
+ }
90
+ focus() {
91
+ super.focus();
92
+ this.list.domFocus();
93
+ }
94
+ layoutBody(height, width) {
95
+ super.layoutBody(height, width);
96
+ this.list.layout(height, width);
97
+ }
98
+ updateBodySize() {
99
+ if (this.orientation === 1 ) {
100
+ return;
101
+ }
102
+ const visibleCount = this.configurationService.getValue('scm.repositories.visible');
103
+ const empty = this.list.length === 0;
104
+ const size = Math.min(this.list.length, visibleCount) * 22;
105
+ this.minimumBodySize = visibleCount === 0 ? 22 : size;
106
+ this.maximumBodySize = visibleCount === 0 ? Number.POSITIVE_INFINITY : empty ? Number.POSITIVE_INFINITY : size;
107
+ }
108
+ onListContextMenu(e) {
109
+ if (!e.element) {
110
+ return;
111
+ }
112
+ const provider = e.element.provider;
113
+ const menus = this.scmViewService.menus.getRepositoryMenus(provider);
114
+ const menu = menus.repositoryContextMenu;
115
+ const actions = collectContextMenuActions(menu);
116
+ const actionRunner = this._register(( new RepositoryActionRunner(() => {
117
+ return this.list.getSelectedElements();
118
+ })));
119
+ actionRunner.onWillRun(() => this.list.domFocus());
120
+ this.contextMenuService.showContextMenu({
121
+ actionRunner,
122
+ getAnchor: () => e.anchor,
123
+ getActions: () => actions,
124
+ getActionsContext: () => provider
125
+ });
126
+ }
127
+ onListSelectionChange(e) {
128
+ if (e.browserEvent && e.elements.length > 0) {
129
+ const scrollTop = this.list.scrollTop;
130
+ this.scmViewService.visibleRepositories = e.elements;
131
+ this.list.scrollTop = scrollTop;
132
+ }
133
+ }
134
+ updateListSelection() {
135
+ const oldSelection = this.list.getSelection();
136
+ const oldSet = ( new Set(( Iterable.map(oldSelection, i => this.list.element(i)))));
137
+ const set = ( new Set(this.scmViewService.visibleRepositories));
138
+ const added = ( new Set(Iterable.filter(set, r => !( oldSet.has(r)))));
139
+ const removed = ( new Set(Iterable.filter(oldSet, r => !( set.has(r)))));
140
+ if (added.size === 0 && removed.size === 0) {
141
+ return;
142
+ }
143
+ const selection = oldSelection
144
+ .filter(i => !( removed.has(this.list.element(i))));
145
+ for (let i = 0; i < this.list.length; i++) {
146
+ if (( added.has(this.list.element(i)))) {
147
+ selection.push(i);
148
+ }
149
+ }
150
+ this.list.setSelection(selection);
151
+ if (selection.length > 0 && selection.indexOf(this.list.getFocus()[0]) === -1) {
152
+ this.list.setAnchor(selection[0]);
153
+ this.list.setFocus([selection[0]]);
154
+ }
155
+ }
156
+ dispose() {
157
+ this.disposables.dispose();
158
+ super.dispose();
159
+ }
160
+ };
161
+ SCMRepositoriesViewPane = ( __decorate([
162
+ ( __param(1, ISCMViewService)),
163
+ ( __param(2, IKeybindingService)),
164
+ ( __param(3, IContextMenuService)),
165
+ ( __param(4, IInstantiationService)),
166
+ ( __param(5, IViewDescriptorService)),
167
+ ( __param(6, IContextKeyService)),
168
+ ( __param(7, IConfigurationService)),
169
+ ( __param(8, IOpenerService)),
170
+ ( __param(9, IThemeService)),
171
+ ( __param(10, ITelemetryService))
172
+ ], SCMRepositoriesViewPane));
173
+
174
+ export { SCMRepositoriesViewPane };
@@ -0,0 +1,136 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/scm.css.js';
3
+ import { combinedDisposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { append, $ } from 'vscode/vscode/vs/base/browser/dom';
5
+ import { ISCMViewService } from 'vscode/vscode/vs/workbench/contrib/scm/common/scm';
6
+ import { CountBadge } from 'vscode/vscode/vs/base/browser/ui/countBadge/countBadge';
7
+ import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
8
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
9
+ import { ActionRunner } from 'vscode/vscode/vs/base/common/actions';
10
+ import { isSCMRepository, connectPrimaryMenu, StatusBarAction } from './util.js';
11
+ import { defaultCountBadgeStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
12
+ import { WorkbenchToolBar } from 'vscode/vscode/vs/platform/actions/browser/toolbar';
13
+ import { MenuId, MenuItemAction, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
14
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
16
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
17
+
18
+ var RepositoryRenderer_1;
19
+ class RepositoryActionRunner extends ActionRunner {
20
+ constructor(getSelectedRepositories) {
21
+ super();
22
+ this.getSelectedRepositories = getSelectedRepositories;
23
+ }
24
+ async runAction(action, context) {
25
+ if (!(action instanceof MenuItemAction)) {
26
+ return super.runAction(action, context);
27
+ }
28
+ const selection = ( this.getSelectedRepositories().map(r => r.provider));
29
+ const actionContext = ( selection.some(s => s === context)) ? selection : [context];
30
+ await action.run(...actionContext);
31
+ }
32
+ }
33
+ let RepositoryRenderer = class RepositoryRenderer {
34
+ static { RepositoryRenderer_1 = this; }
35
+ static { this.TEMPLATE_ID = 'repository'; }
36
+ get templateId() { return RepositoryRenderer_1.TEMPLATE_ID; }
37
+ constructor(toolbarMenuId, actionViewItemProvider, scmViewService, commandService, contextKeyService, contextMenuService, keybindingService, menuService, telemetryService) {
38
+ this.toolbarMenuId = toolbarMenuId;
39
+ this.actionViewItemProvider = actionViewItemProvider;
40
+ this.scmViewService = scmViewService;
41
+ this.commandService = commandService;
42
+ this.contextKeyService = contextKeyService;
43
+ this.contextMenuService = contextMenuService;
44
+ this.keybindingService = keybindingService;
45
+ this.menuService = menuService;
46
+ this.telemetryService = telemetryService;
47
+ }
48
+ renderTemplate(container) {
49
+ if (container.classList.contains('monaco-tl-contents')) {
50
+ container.parentElement.parentElement.querySelector('.monaco-tl-twistie').classList.add('force-twistie');
51
+ }
52
+ const provider = append(container, $('.scm-provider'));
53
+ const label = append(provider, $('.label'));
54
+ const name = append(label, $('span.name'));
55
+ const description = append(label, $('span.description'));
56
+ const actions = append(provider, $('.actions'));
57
+ const toolBar = ( new WorkbenchToolBar(
58
+ actions,
59
+ { actionViewItemProvider: this.actionViewItemProvider, resetMenu: this.toolbarMenuId },
60
+ this.menuService,
61
+ this.contextKeyService,
62
+ this.contextMenuService,
63
+ this.keybindingService,
64
+ this.telemetryService
65
+ ));
66
+ const countContainer = append(provider, $('.count'));
67
+ const count = ( new CountBadge(countContainer, {}, defaultCountBadgeStyles));
68
+ const visibilityDisposable = toolBar.onDidChangeDropdownVisibility(e => provider.classList.toggle('active', e));
69
+ const templateDisposable = combinedDisposable(visibilityDisposable, toolBar);
70
+ return { label, name, description, countContainer, count, toolBar, elementDisposables: ( new DisposableStore()), templateDisposable };
71
+ }
72
+ renderElement(arg, index, templateData, height) {
73
+ const repository = isSCMRepository(arg) ? arg : arg.element;
74
+ templateData.name.textContent = repository.provider.name;
75
+ if (repository.provider.rootUri) {
76
+ templateData.label.title = `${repository.provider.label}: ${repository.provider.rootUri.fsPath}`;
77
+ templateData.description.textContent = repository.provider.label;
78
+ }
79
+ else {
80
+ templateData.label.title = repository.provider.label;
81
+ templateData.description.textContent = '';
82
+ }
83
+ let statusPrimaryActions = [];
84
+ let menuPrimaryActions = [];
85
+ let menuSecondaryActions = [];
86
+ const updateToolbar = () => {
87
+ templateData.toolBar.setActions([...statusPrimaryActions, ...menuPrimaryActions], menuSecondaryActions);
88
+ };
89
+ const onDidChangeProvider = () => {
90
+ const commands = repository.provider.statusBarCommands || [];
91
+ statusPrimaryActions = ( commands.map(c => ( new StatusBarAction(c, this.commandService))));
92
+ updateToolbar();
93
+ const count = repository.provider.count || 0;
94
+ templateData.countContainer.setAttribute('data-count', String(count));
95
+ templateData.count.setCount(count);
96
+ };
97
+ let disposed = false;
98
+ templateData.elementDisposables.add(toDisposable(() => disposed = true));
99
+ templateData.elementDisposables.add(repository.provider.onDidChange(() => {
100
+ if (disposed) {
101
+ return;
102
+ }
103
+ onDidChangeProvider();
104
+ }));
105
+ onDidChangeProvider();
106
+ const repositoryMenus = this.scmViewService.menus.getRepositoryMenus(repository.provider);
107
+ const menu = this.toolbarMenuId === MenuId.SCMTitle ? repositoryMenus.titleMenu.menu : repositoryMenus.repositoryMenu;
108
+ templateData.elementDisposables.add(connectPrimaryMenu(menu, (primary, secondary) => {
109
+ menuPrimaryActions = primary;
110
+ menuSecondaryActions = secondary;
111
+ updateToolbar();
112
+ }));
113
+ templateData.toolBar.context = repository.provider;
114
+ }
115
+ renderCompressedElements() {
116
+ throw new Error('Should never happen since node is incompressible');
117
+ }
118
+ disposeElement(group, index, template) {
119
+ template.elementDisposables.clear();
120
+ }
121
+ disposeTemplate(templateData) {
122
+ templateData.elementDisposables.dispose();
123
+ templateData.templateDisposable.dispose();
124
+ }
125
+ };
126
+ RepositoryRenderer = RepositoryRenderer_1 = ( __decorate([
127
+ ( __param(2, ISCMViewService)),
128
+ ( __param(3, ICommandService)),
129
+ ( __param(4, IContextKeyService)),
130
+ ( __param(5, IContextMenuService)),
131
+ ( __param(6, IKeybindingService)),
132
+ ( __param(7, IMenuService)),
133
+ ( __param(8, ITelemetryService))
134
+ ], RepositoryRenderer));
135
+
136
+ export { RepositoryActionRunner, RepositoryRenderer };