@codingame/monaco-vscode-api 3.0.0 → 3.1.1

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.
Files changed (40) hide show
  1. package/api.js +1 -1
  2. package/assets/continue-tb.png +0 -0
  3. package/assets/pause-tb.png +0 -0
  4. package/assets/restart-tb.png +0 -0
  5. package/assets/run-with-debugging-tb.png +0 -0
  6. package/assets/stepinto-tb.png +0 -0
  7. package/assets/stepout-tb.png +0 -0
  8. package/assets/stepover-tb.png +0 -0
  9. package/assets/stop-tb.png +0 -0
  10. package/contributions.js +2 -0
  11. package/l10n.js +4 -1
  12. package/missing-services.js +17 -2
  13. package/package.json +8 -8
  14. package/service-override/tools/editorAssets.js +3 -0
  15. package/services.d.ts +6 -3
  16. package/services.js +17 -3
  17. package/vscode/src/vs/base/common/lifecycle.js +158 -1
  18. package/vscode/src/vs/base/common/observableInternal/autorun.js +3 -1
  19. package/vscode/src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.js +3 -0
  20. package/vscode/src/vs/nls.js +8 -1
  21. package/vscode/src/vs/platform/tunnel/common/tunnel.js +267 -1
  22. package/vscode/src/vs/workbench/api/common/extHost.api.impl.js +1 -1
  23. package/vscode/src/vs/workbench/api/common/extHostNotebookDocument.js +1 -11
  24. package/vscode/src/vs/workbench/browser/actions/developerActions.js +703 -0
  25. package/vscode/src/vs/workbench/browser/actions/media/actions.css.js +4 -0
  26. package/vscode/src/vs/workbench/browser/actions/navigationActions.js +300 -0
  27. package/vscode/src/vs/workbench/browser/actions/textInputActions.js +83 -0
  28. package/vscode/src/vs/workbench/browser/dnd.js +2 -1
  29. package/vscode/src/vs/workbench/browser/parts/globalCompositeBar.js +323 -8
  30. package/vscode/src/vs/workbench/common/contributions.d.ts +44 -1
  31. package/vscode/src/vs/workbench/common/contributions.js +8 -1
  32. package/vscode/src/vs/workbench/common/views.js +1 -3
  33. package/vscode/src/vs/workbench/contrib/debug/browser/media/all.png.js +11 -0
  34. package/vscode/src/vs/workbench/contrib/files/browser/files.editorPane.contribution.js +67 -0
  35. package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.js +140 -0
  36. package/vscode/src/vs/workbench/services/workspaces/common/workspaceIdentityService.js +102 -0
  37. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +0 -430
  38. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +0 -786
  39. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +0 -510
  40. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +0 -522
@@ -0,0 +1,140 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { getLogLevel, ILogService, ILoggerService, LogLevelToString, parseLogLevel } from '../../../../platform/log/common/log.js';
3
+ import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
4
+ import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
5
+ import { toFileOperationResult, IFileService } from '../../../../platform/files/common/files.js';
6
+ import { IJSONEditingService } from '../../../services/configuration/common/jsonEditing.js';
7
+ import { isUndefined, isString } from '../../../../base/common/types.js';
8
+ import { EXTENSION_IDENTIFIER_WITH_LOG_REGEX } from '../../../../platform/environment/common/environmentService.js';
9
+ import { parse } from '../../../../base/common/json.js';
10
+ const IDefaultLogLevelsService = ( createDecorator('IDefaultLogLevelsService'));
11
+ let DefaultLogLevelsService = class DefaultLogLevelsService {
12
+ constructor(environmentService, fileService, jsonEditingService, logService, loggerService) {
13
+ this.environmentService = environmentService;
14
+ this.fileService = fileService;
15
+ this.jsonEditingService = jsonEditingService;
16
+ this.logService = logService;
17
+ this.loggerService = loggerService;
18
+ }
19
+ async getDefaultLogLevels() {
20
+ const argvLogLevel = await this._parseLogLevelsFromArgv();
21
+ return {
22
+ default: argvLogLevel?.default ?? this._getDefaultLogLevelFromEnv(),
23
+ extensions: argvLogLevel?.extensions ?? this._getExtensionsDefaultLogLevelsFromEnv()
24
+ };
25
+ }
26
+ async setDefaultLogLevel(defaultLogLevel, extensionId) {
27
+ const argvLogLevel = (await this._parseLogLevelsFromArgv()) ?? {};
28
+ if (extensionId) {
29
+ extensionId = extensionId.toLowerCase();
30
+ const argvLogLevel = (await this._parseLogLevelsFromArgv()) ?? {};
31
+ const currentDefaultLogLevel = this._getDefaultLogLevel(argvLogLevel, extensionId);
32
+ argvLogLevel.extensions = argvLogLevel.extensions ?? [];
33
+ const extension = argvLogLevel.extensions.find(([extension]) => extension === extensionId);
34
+ if (extension) {
35
+ extension[1] = defaultLogLevel;
36
+ }
37
+ else {
38
+ argvLogLevel.extensions.push([extensionId, defaultLogLevel]);
39
+ }
40
+ await this._writeLogLevelsToArgv(argvLogLevel);
41
+ const extensionLoggers = [...this.loggerService.getRegisteredLoggers()].filter(logger => logger.extensionId && logger.extensionId.toLowerCase() === extensionId);
42
+ for (const { resource } of extensionLoggers) {
43
+ if (this.loggerService.getLogLevel(resource) === currentDefaultLogLevel) {
44
+ this.loggerService.setLogLevel(resource, defaultLogLevel);
45
+ }
46
+ }
47
+ }
48
+ else {
49
+ const currentLogLevel = this._getDefaultLogLevel(argvLogLevel);
50
+ argvLogLevel.default = defaultLogLevel;
51
+ await this._writeLogLevelsToArgv(argvLogLevel);
52
+ if (this.loggerService.getLogLevel() === currentLogLevel) {
53
+ this.loggerService.setLogLevel(defaultLogLevel);
54
+ }
55
+ }
56
+ }
57
+ _getDefaultLogLevel(argvLogLevels, extension) {
58
+ if (extension) {
59
+ const extensionLogLevel = argvLogLevels.extensions?.find(([extensionId]) => extensionId === extension);
60
+ if (extensionLogLevel) {
61
+ return extensionLogLevel[1];
62
+ }
63
+ }
64
+ return argvLogLevels.default ?? getLogLevel(this.environmentService);
65
+ }
66
+ async _writeLogLevelsToArgv(logLevels) {
67
+ const logLevelsValue = [];
68
+ if (!isUndefined(logLevels.default)) {
69
+ logLevelsValue.push(LogLevelToString(logLevels.default));
70
+ }
71
+ for (const [extension, logLevel] of logLevels.extensions ?? []) {
72
+ logLevelsValue.push(`${extension}=${LogLevelToString(logLevel)}`);
73
+ }
74
+ await this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['log-level'], value: logLevelsValue.length ? logLevelsValue : undefined }], true);
75
+ }
76
+ async _parseLogLevelsFromArgv() {
77
+ const result = { extensions: [] };
78
+ const logLevels = await this._readLogLevelsFromArgv();
79
+ for (const extensionLogLevel of logLevels) {
80
+ const matches = EXTENSION_IDENTIFIER_WITH_LOG_REGEX.exec(extensionLogLevel);
81
+ if (matches && matches[1] && matches[2]) {
82
+ const logLevel = parseLogLevel(matches[2]);
83
+ if (!isUndefined(logLevel)) {
84
+ result.extensions?.push([matches[1].toLowerCase(), logLevel]);
85
+ }
86
+ }
87
+ else {
88
+ const logLevel = parseLogLevel(extensionLogLevel);
89
+ if (!isUndefined(logLevel)) {
90
+ result.default = logLevel;
91
+ }
92
+ }
93
+ }
94
+ return !isUndefined(result.default) || result.extensions?.length ? result : undefined;
95
+ }
96
+ async migrateLogLevels() {
97
+ const logLevels = await this._readLogLevelsFromArgv();
98
+ const regex = /^([^.]+\..+):(.+)$/;
99
+ if (( logLevels.some(extensionLogLevel => regex.test(extensionLogLevel)))) {
100
+ const argvLogLevel = await this._parseLogLevelsFromArgv();
101
+ if (argvLogLevel) {
102
+ await this._writeLogLevelsToArgv(argvLogLevel);
103
+ }
104
+ }
105
+ }
106
+ async _readLogLevelsFromArgv() {
107
+ try {
108
+ const content = await this.fileService.readFile(this.environmentService.argvResource);
109
+ const argv = parse(( content.value.toString()));
110
+ return isString(argv['log-level']) ? [argv['log-level']] : Array.isArray(argv['log-level']) ? argv['log-level'] : [];
111
+ }
112
+ catch (error) {
113
+ if (toFileOperationResult(error) !== 1 ) {
114
+ this.logService.error(error);
115
+ }
116
+ }
117
+ return [];
118
+ }
119
+ _getDefaultLogLevelFromEnv() {
120
+ return getLogLevel(this.environmentService);
121
+ }
122
+ _getExtensionsDefaultLogLevelsFromEnv() {
123
+ const result = [];
124
+ for (const [extension, logLevelValue] of this.environmentService.extensionLogLevel ?? []) {
125
+ const logLevel = parseLogLevel(logLevelValue);
126
+ if (!isUndefined(logLevel)) {
127
+ result.push([extension, logLevel]);
128
+ }
129
+ }
130
+ return result;
131
+ }
132
+ };
133
+ DefaultLogLevelsService = ( __decorate([
134
+ ( __param(0, IWorkbenchEnvironmentService)),
135
+ ( __param(1, IFileService)),
136
+ ( __param(2, IJSONEditingService)),
137
+ ( __param(3, ILogService)),
138
+ ( __param(4, ILoggerService))
139
+ ], DefaultLogLevelsService));
140
+ export { DefaultLogLevelsService, IDefaultLogLevelsService };
@@ -0,0 +1,102 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { VSBuffer } from '../../../../base/common/buffer.js';
3
+ import { isEqualOrParent, relativePath, joinPath } from '../../../../base/common/resources.js';
4
+ import { URI } from '../../../../base/common/uri.js';
5
+ import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
6
+ import { EditSessionIdentityMatch, IEditSessionIdentityService } from '../../../../platform/workspace/common/editSessions.js';
7
+ import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
8
+ const IWorkspaceIdentityService = ( createDecorator('IWorkspaceIdentityService'));
9
+ let WorkspaceIdentityService = class WorkspaceIdentityService {
10
+ constructor(workspaceContextService, editSessionIdentityService) {
11
+ this.workspaceContextService = workspaceContextService;
12
+ this.editSessionIdentityService = editSessionIdentityService;
13
+ }
14
+ async getWorkspaceStateFolders(cancellationToken) {
15
+ const workspaceStateFolders = [];
16
+ for (const workspaceFolder of this.workspaceContextService.getWorkspace().folders) {
17
+ const workspaceFolderIdentity = await this.editSessionIdentityService.getEditSessionIdentifier(workspaceFolder, cancellationToken);
18
+ if (!workspaceFolderIdentity) {
19
+ continue;
20
+ }
21
+ workspaceStateFolders.push({ resourceUri: ( workspaceFolder.uri.toString()), workspaceFolderIdentity });
22
+ }
23
+ return workspaceStateFolders;
24
+ }
25
+ async matches(incomingWorkspaceFolders, cancellationToken) {
26
+ const incomingToCurrentWorkspaceFolderUris = {};
27
+ const incomingIdentitiesToIncomingWorkspaceFolders = {};
28
+ for (const workspaceFolder of incomingWorkspaceFolders) {
29
+ incomingIdentitiesToIncomingWorkspaceFolders[workspaceFolder.workspaceFolderIdentity] = workspaceFolder.resourceUri;
30
+ }
31
+ const currentWorkspaceFoldersToIdentities = ( new Map());
32
+ for (const workspaceFolder of this.workspaceContextService.getWorkspace().folders) {
33
+ const workspaceFolderIdentity = await this.editSessionIdentityService.getEditSessionIdentifier(workspaceFolder, cancellationToken);
34
+ if (!workspaceFolderIdentity) {
35
+ continue;
36
+ }
37
+ currentWorkspaceFoldersToIdentities.set(workspaceFolder, workspaceFolderIdentity);
38
+ }
39
+ for (const [currentWorkspaceFolder, currentWorkspaceFolderIdentity] of currentWorkspaceFoldersToIdentities.entries()) {
40
+ const incomingWorkspaceFolder = incomingIdentitiesToIncomingWorkspaceFolders[currentWorkspaceFolderIdentity];
41
+ if (incomingWorkspaceFolder) {
42
+ incomingToCurrentWorkspaceFolderUris[incomingWorkspaceFolder] = ( currentWorkspaceFolder.uri.toString());
43
+ continue;
44
+ }
45
+ let hasCompleteMatch = false;
46
+ for (const [incomingIdentity, incomingFolder] of Object.entries(incomingIdentitiesToIncomingWorkspaceFolders)) {
47
+ if ((await this.editSessionIdentityService.provideEditSessionIdentityMatch(currentWorkspaceFolder, currentWorkspaceFolderIdentity, incomingIdentity, cancellationToken)) === EditSessionIdentityMatch.Complete) {
48
+ incomingToCurrentWorkspaceFolderUris[incomingFolder] = ( currentWorkspaceFolder.uri.toString());
49
+ hasCompleteMatch = true;
50
+ break;
51
+ }
52
+ }
53
+ if (hasCompleteMatch) {
54
+ continue;
55
+ }
56
+ return false;
57
+ }
58
+ const convertUri = (uriToConvert) => {
59
+ for (const incomingFolderUriKey of ( Object.keys(incomingToCurrentWorkspaceFolderUris))) {
60
+ const incomingFolderUri = ( URI.parse(incomingFolderUriKey));
61
+ if (isEqualOrParent(incomingFolderUri, uriToConvert)) {
62
+ const currentWorkspaceFolderUri = incomingToCurrentWorkspaceFolderUris[incomingFolderUriKey];
63
+ const relativeFilePath = relativePath(incomingFolderUri, uriToConvert);
64
+ if (relativeFilePath) {
65
+ return joinPath(( URI.parse(currentWorkspaceFolderUri)), relativeFilePath);
66
+ }
67
+ }
68
+ }
69
+ return uriToConvert;
70
+ };
71
+ const uriReplacer = (obj, depth = 0) => {
72
+ if (!obj || depth > 200) {
73
+ return obj;
74
+ }
75
+ if (obj instanceof VSBuffer || obj instanceof Uint8Array) {
76
+ return obj;
77
+ }
78
+ if (URI.isUri(obj)) {
79
+ return convertUri(obj);
80
+ }
81
+ if (Array.isArray(obj)) {
82
+ for (let i = 0; i < obj.length; ++i) {
83
+ obj[i] = uriReplacer(obj[i], depth + 1);
84
+ }
85
+ }
86
+ else {
87
+ for (const key in obj) {
88
+ if (Object.hasOwnProperty.call(obj, key)) {
89
+ obj[key] = uriReplacer(obj[key], depth + 1);
90
+ }
91
+ }
92
+ }
93
+ return obj;
94
+ };
95
+ return uriReplacer;
96
+ }
97
+ };
98
+ WorkspaceIdentityService = ( __decorate([
99
+ ( __param(0, IWorkspaceContextService)),
100
+ ( __param(1, IEditSessionIdentityService))
101
+ ], WorkspaceIdentityService));
102
+ export { IWorkspaceIdentityService, WorkspaceIdentityService };
@@ -1,430 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { Event } from '../../../../base/common/event.js';
3
- import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
4
- import { DisposableStore } from '../../../../base/common/lifecycle.js';
5
- import { ExplorerModel, ExplorerItem } from '../common/explorerModel.js';
6
- import { IFileService } from '../../../../platform/files/common/files.js';
7
- import { dirname, basename } from '../../../../base/common/resources.js';
8
- import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
9
- import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
10
- import { IEditorService } from '../../../services/editor/common/editorService.js';
11
- import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
12
- import { IBulkEditService } from '../../../../editor/browser/services/bulkEditService.js';
13
- import { UndoRedoSource } from '../../../../platform/undoRedo/common/undoRedo.js';
14
- import { IProgressService } from '../../../../platform/progress/common/progress.js';
15
- import { CancellationTokenSource } from '../../../../base/common/cancellation.js';
16
- import { RunOnceScheduler } from '../../../../base/common/async.js';
17
- import { IHostService } from '../../../services/host/browser/host.js';
18
- import { ResourceGlobMatcher } from '../../../common/resources.js';
19
- import { IFilesConfigurationService } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
20
- import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
21
- var ExplorerService_1;
22
- const UNDO_REDO_SOURCE = ( new UndoRedoSource());
23
- let ExplorerService = class ExplorerService {
24
- static { ExplorerService_1 = this; }
25
- static { this.EXPLORER_FILE_CHANGES_REACT_DELAY = 500; }
26
- constructor(fileService, configurationService, contextService, clipboardService, editorService, uriIdentityService, bulkEditService, progressService, hostService, filesConfigurationService, telemetryService) {
27
- this.fileService = fileService;
28
- this.configurationService = configurationService;
29
- this.contextService = contextService;
30
- this.clipboardService = clipboardService;
31
- this.editorService = editorService;
32
- this.uriIdentityService = uriIdentityService;
33
- this.bulkEditService = bulkEditService;
34
- this.progressService = progressService;
35
- this.filesConfigurationService = filesConfigurationService;
36
- this.telemetryService = telemetryService;
37
- this.disposables = ( new DisposableStore());
38
- this.fileChangeEvents = [];
39
- this.config = this.configurationService.getValue('explorer');
40
- this.model = ( new ExplorerModel(
41
- this.contextService,
42
- this.uriIdentityService,
43
- this.fileService,
44
- this.configurationService,
45
- this.filesConfigurationService
46
- ));
47
- this.disposables.add(this.model);
48
- this.disposables.add(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e)));
49
- this.onFileChangesScheduler = ( new RunOnceScheduler(async () => {
50
- const events = this.fileChangeEvents;
51
- this.fileChangeEvents = [];
52
- const types = [2 ];
53
- if (this.config.sortOrder === "modified" ) {
54
- types.push(0 );
55
- }
56
- let shouldRefresh = false;
57
- this.roots.forEach(r => {
58
- if (this.view && !shouldRefresh) {
59
- shouldRefresh = doesFileEventAffect(r, this.view, events, types);
60
- }
61
- });
62
- events.forEach(e => {
63
- if (!shouldRefresh) {
64
- for (const resource of e.rawAdded) {
65
- const parent = this.model.findClosest(dirname(resource));
66
- if (parent && !parent.getChild(basename(resource))) {
67
- shouldRefresh = true;
68
- break;
69
- }
70
- }
71
- }
72
- });
73
- if (shouldRefresh) {
74
- await this.refresh(false);
75
- }
76
- }, ExplorerService_1.EXPLORER_FILE_CHANGES_REACT_DELAY));
77
- this.disposables.add(this.fileService.onDidFilesChange(e => {
78
- this.fileChangeEvents.push(e);
79
- if (this.editable) {
80
- return;
81
- }
82
- if (!this.onFileChangesScheduler.isScheduled()) {
83
- this.onFileChangesScheduler.schedule();
84
- }
85
- }));
86
- this.disposables.add(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
87
- this.disposables.add(Event.any(this.fileService.onDidChangeFileSystemProviderRegistrations, this.fileService.onDidChangeFileSystemProviderCapabilities)(async (e) => {
88
- let affected = false;
89
- this.model.roots.forEach(r => {
90
- if (r.resource.scheme === e.scheme) {
91
- affected = true;
92
- r.forgetChildren();
93
- }
94
- });
95
- if (affected) {
96
- if (this.view) {
97
- await this.view.setTreeInput();
98
- }
99
- }
100
- }));
101
- this.disposables.add(this.model.onDidChangeRoots(() => {
102
- this.view?.setTreeInput();
103
- }));
104
- this.disposables.add(hostService.onDidChangeFocus(hasFocus => {
105
- if (hasFocus) {
106
- this.refresh(false);
107
- }
108
- }));
109
- this.revealExcludeMatcher = ( new ResourceGlobMatcher(
110
- (uri) => getRevealExcludes(configurationService.getValue({ resource: uri })),
111
- (event) => event.affectsConfiguration('explorer.autoRevealExclude'),
112
- contextService,
113
- configurationService
114
- ));
115
- this.disposables.add(this.revealExcludeMatcher);
116
- }
117
- get roots() {
118
- return this.model.roots;
119
- }
120
- get sortOrderConfiguration() {
121
- return {
122
- sortOrder: this.config.sortOrder,
123
- lexicographicOptions: this.config.sortOrderLexicographicOptions,
124
- };
125
- }
126
- registerView(contextProvider) {
127
- this.view = contextProvider;
128
- }
129
- getContext(respectMultiSelection, ignoreNestedChildren = false) {
130
- if (!this.view) {
131
- return [];
132
- }
133
- const items = ( new Set(this.view.getContext(respectMultiSelection)));
134
- items.forEach(item => {
135
- try {
136
- if (respectMultiSelection && !ignoreNestedChildren && this.view?.isItemCollapsed(item) && item.nestedChildren) {
137
- for (const child of item.nestedChildren) {
138
- items.add(child);
139
- }
140
- }
141
- }
142
- catch {
143
- return;
144
- }
145
- });
146
- return [...items];
147
- }
148
- async applyBulkEdit(edit, options) {
149
- const cancellationTokenSource = ( new CancellationTokenSource());
150
- const promise = this.progressService.withProgress({
151
- location: options.progressLocation || 10 ,
152
- title: options.progressLabel,
153
- cancellable: edit.length > 1,
154
- delay: 500,
155
- }, async (progress) => {
156
- await this.bulkEditService.apply(edit, {
157
- undoRedoSource: UNDO_REDO_SOURCE,
158
- label: options.undoLabel,
159
- code: 'undoredo.explorerOperation',
160
- progress,
161
- token: cancellationTokenSource.token,
162
- confirmBeforeUndo: options.confirmBeforeUndo
163
- });
164
- }, () => cancellationTokenSource.cancel());
165
- await this.progressService.withProgress({ location: 1 , delay: 500 }, () => promise);
166
- cancellationTokenSource.dispose();
167
- }
168
- hasViewFocus() {
169
- return !!this.view && this.view.hasFocus();
170
- }
171
- findClosest(resource) {
172
- return this.model.findClosest(resource);
173
- }
174
- findClosestRoot(resource) {
175
- const parentRoots = this.model.roots.filter(r => this.uriIdentityService.extUri.isEqualOrParent(resource, r.resource))
176
- .sort((first, second) => second.resource.path.length - first.resource.path.length);
177
- return parentRoots.length ? parentRoots[0] : null;
178
- }
179
- async setEditable(stat, data) {
180
- if (!this.view) {
181
- return;
182
- }
183
- if (!data) {
184
- this.editable = undefined;
185
- }
186
- else {
187
- this.editable = { stat, data };
188
- }
189
- const isEditing = this.isEditable(stat);
190
- try {
191
- await this.view.setEditable(stat, isEditing);
192
- }
193
- catch {
194
- const parent = stat.parent;
195
- const errorData = {
196
- parentIsDirectory: parent?.isDirectory,
197
- isDirectory: stat.isDirectory,
198
- isReadonly: !!stat.isReadonly,
199
- parentIsReadonly: !!parent?.isReadonly,
200
- parentIsExcluded: parent?.isExcluded,
201
- isExcluded: stat.isExcluded,
202
- parentIsRoot: parent?.isRoot,
203
- isRoot: stat.isRoot,
204
- parentHasNests: parent?.hasNests,
205
- hasNests: stat.hasNests,
206
- };
207
- this.telemetryService.publicLogError2('explorerView.setEditableError', errorData);
208
- return;
209
- }
210
- if (!this.editable && this.fileChangeEvents.length && !this.onFileChangesScheduler.isScheduled()) {
211
- this.onFileChangesScheduler.schedule();
212
- }
213
- }
214
- async setToCopy(items, cut) {
215
- const previouslyCutItems = this.cutItems;
216
- this.cutItems = cut ? items : undefined;
217
- await this.clipboardService.writeResources(( items.map(s => s.resource)));
218
- this.view?.itemsCopied(items, cut, previouslyCutItems);
219
- }
220
- isCut(item) {
221
- return !!this.cutItems && ( this.cutItems.some(i => this.uriIdentityService.extUri.isEqual(i.resource, item.resource)));
222
- }
223
- getEditable() {
224
- return this.editable;
225
- }
226
- getEditableData(stat) {
227
- return this.editable && this.editable.stat === stat ? this.editable.data : undefined;
228
- }
229
- isEditable(stat) {
230
- return !!this.editable && (this.editable.stat === stat || !stat);
231
- }
232
- async select(resource, reveal) {
233
- if (!this.view) {
234
- return;
235
- }
236
- const ignoreRevealExcludes = reveal === 'force';
237
- const fileStat = this.findClosest(resource);
238
- if (fileStat) {
239
- if (!this.shouldAutoRevealItem(fileStat, ignoreRevealExcludes)) {
240
- return;
241
- }
242
- await this.view.selectResource(fileStat.resource, reveal);
243
- return Promise.resolve(undefined);
244
- }
245
- const options = { resolveTo: [resource], resolveMetadata: this.config.sortOrder === "modified" };
246
- const root = this.findClosestRoot(resource);
247
- if (!root) {
248
- return undefined;
249
- }
250
- try {
251
- const stat = await this.fileService.resolve(root.resource, options);
252
- const modelStat = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, stat, undefined, options.resolveTo);
253
- ExplorerItem.mergeLocalWithDisk(modelStat, root);
254
- const item = root.find(resource);
255
- await this.view.refresh(true, root);
256
- if (item && !this.shouldAutoRevealItem(item, ignoreRevealExcludes)) {
257
- return;
258
- }
259
- await this.view.selectResource(item ? item.resource : undefined, reveal);
260
- }
261
- catch (error) {
262
- root.error = error;
263
- await this.view.refresh(false, root);
264
- }
265
- }
266
- async refresh(reveal = true) {
267
- this.model.roots.forEach(r => r.forgetChildren());
268
- if (this.view) {
269
- await this.view.refresh(true);
270
- const resource = this.editorService.activeEditor?.resource;
271
- const autoReveal = this.configurationService.getValue().explorer.autoReveal;
272
- if (reveal && resource && autoReveal) {
273
- this.select(resource, autoReveal);
274
- }
275
- }
276
- }
277
- async onDidRunOperation(e) {
278
- const shouldDeepRefresh = this.config.fileNesting.enabled;
279
- if (e.isOperation(0 ) || e.isOperation(3 )) {
280
- const addedElement = e.target;
281
- const parentResource = dirname(addedElement.resource);
282
- const parents = this.model.findAll(parentResource);
283
- if (parents.length) {
284
- await Promise.all(( parents.map(async (p) => {
285
- const resolveMetadata = this.config.sortOrder === `modified`;
286
- if (!p.isDirectoryResolved) {
287
- const stat = await this.fileService.resolve(p.resource, { resolveMetadata });
288
- if (stat) {
289
- const modelStat = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, stat, p.parent);
290
- ExplorerItem.mergeLocalWithDisk(modelStat, p);
291
- }
292
- }
293
- const childElement = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, addedElement, p.parent);
294
- p.removeChild(childElement);
295
- p.addChild(childElement);
296
- await this.view?.refresh(shouldDeepRefresh, p);
297
- })));
298
- }
299
- }
300
- else if (e.isOperation(2 )) {
301
- const oldResource = e.resource;
302
- const newElement = e.target;
303
- const oldParentResource = dirname(oldResource);
304
- const newParentResource = dirname(newElement.resource);
305
- const modelElements = this.model.findAll(oldResource);
306
- const sameParentMove = modelElements.every(e => !e.nestedParent) && this.uriIdentityService.extUri.isEqual(oldParentResource, newParentResource);
307
- if (sameParentMove) {
308
- await Promise.all(( modelElements.map(async (modelElement) => {
309
- modelElement.rename(newElement);
310
- await this.view?.refresh(shouldDeepRefresh, modelElement.parent);
311
- })));
312
- }
313
- else {
314
- const newParents = this.model.findAll(newParentResource);
315
- if (newParents.length && modelElements.length) {
316
- await Promise.all(( modelElements.map(async (modelElement, index) => {
317
- const oldParent = modelElement.parent;
318
- const oldNestedParent = modelElement.nestedParent;
319
- modelElement.move(newParents[index]);
320
- if (oldNestedParent) {
321
- await this.view?.refresh(false, oldNestedParent);
322
- }
323
- await this.view?.refresh(false, oldParent);
324
- await this.view?.refresh(shouldDeepRefresh, newParents[index]);
325
- })));
326
- }
327
- }
328
- }
329
- else if (e.isOperation(1 )) {
330
- const modelElements = this.model.findAll(e.resource);
331
- await Promise.all(( modelElements.map(async (modelElement) => {
332
- if (modelElement.parent) {
333
- const parent = modelElement.parent;
334
- parent.removeChild(modelElement);
335
- this.view?.focusNext();
336
- const oldNestedParent = modelElement.nestedParent;
337
- if (oldNestedParent) {
338
- oldNestedParent.removeChild(modelElement);
339
- await this.view?.refresh(false, oldNestedParent);
340
- }
341
- await this.view?.refresh(shouldDeepRefresh, parent);
342
- if (this.view?.getFocus().length === 0) {
343
- this.view?.focusLast();
344
- }
345
- }
346
- })));
347
- }
348
- }
349
- shouldAutoRevealItem(item, ignore) {
350
- if (item === undefined || ignore) {
351
- return true;
352
- }
353
- if (this.revealExcludeMatcher.matches(item.resource, name => !!(item.parent && item.parent.getChild(name)))) {
354
- return false;
355
- }
356
- const root = item.root;
357
- let currentItem = item.parent;
358
- while (currentItem !== root) {
359
- if (currentItem === undefined) {
360
- return true;
361
- }
362
- if (this.revealExcludeMatcher.matches(currentItem.resource)) {
363
- return false;
364
- }
365
- currentItem = currentItem.parent;
366
- }
367
- return true;
368
- }
369
- async onConfigurationUpdated(event) {
370
- if (!event.affectsConfiguration('explorer')) {
371
- return;
372
- }
373
- let shouldRefresh = false;
374
- if (event.affectsConfiguration('explorer.fileNesting')) {
375
- shouldRefresh = true;
376
- }
377
- const configuration = this.configurationService.getValue();
378
- const configSortOrder = configuration?.explorer?.sortOrder || "default" ;
379
- if (this.config.sortOrder !== configSortOrder) {
380
- shouldRefresh = this.config.sortOrder !== undefined;
381
- }
382
- const configLexicographicOptions = configuration?.explorer?.sortOrderLexicographicOptions || "default" ;
383
- if (this.config.sortOrderLexicographicOptions !== configLexicographicOptions) {
384
- shouldRefresh = shouldRefresh || this.config.sortOrderLexicographicOptions !== undefined;
385
- }
386
- this.config = configuration.explorer;
387
- if (shouldRefresh) {
388
- await this.refresh();
389
- }
390
- }
391
- dispose() {
392
- this.disposables.dispose();
393
- }
394
- };
395
- ExplorerService = ExplorerService_1 = ( __decorate([
396
- ( __param(0, IFileService)),
397
- ( __param(1, IConfigurationService)),
398
- ( __param(2, IWorkspaceContextService)),
399
- ( __param(3, IClipboardService)),
400
- ( __param(4, IEditorService)),
401
- ( __param(5, IUriIdentityService)),
402
- ( __param(6, IBulkEditService)),
403
- ( __param(7, IProgressService)),
404
- ( __param(8, IHostService)),
405
- ( __param(9, IFilesConfigurationService)),
406
- ( __param(10, ITelemetryService))
407
- ], ExplorerService));
408
- function doesFileEventAffect(item, view, events, types) {
409
- for (const [_name, child] of item.children) {
410
- if (view.isItemVisible(child)) {
411
- if (( events.some(e => e.contains(child.resource, ...types)))) {
412
- return true;
413
- }
414
- if (child.isDirectory && child.isDirectoryResolved) {
415
- if (doesFileEventAffect(child, view, events, types)) {
416
- return true;
417
- }
418
- }
419
- }
420
- }
421
- return false;
422
- }
423
- function getRevealExcludes(configuration) {
424
- const revealExcludes = configuration && configuration.explorer && configuration.explorer.autoRevealExclude;
425
- if (!revealExcludes) {
426
- return {};
427
- }
428
- return revealExcludes;
429
- }
430
- export { ExplorerService, UNDO_REDO_SOURCE };