@codingame/monaco-vscode-base-service-override 4.4.1 → 4.5.0
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.
- package/base.js +16 -13
- package/package.json +10 -2
- package/vscode/src/vs/platform/download/common/downloadService.js +3 -2
- package/vscode/src/vs/platform/request/browser/requestService.js +2 -2
- package/vscode/src/vs/workbench/services/configuration/common/jsonEditing.js +8 -0
- package/vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js +4 -3
- package/vscode/src/vs/workbench/services/decorations/browser/decorationsService.js +3 -3
- package/vscode/src/vs/workbench/services/path/browser/pathService.js +1 -6
- package/vscode/src/vs/workbench/services/path/common/pathService.js +108 -0
- package/vscode/src/vs/workbench/services/request/browser/requestService.js +3 -3
- package/vscode/src/vs/workbench/services/url/browser/urlService.js +3 -3
- package/vscode/src/vs/workbench/services/userActivity/common/userActivityRegistry.js +16 -0
- package/vscode/src/vs/workbench/services/userActivity/common/userActivityService.js +38 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopySaveParticipant.js +64 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.js +42 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.js +182 -0
package/base.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
3
|
-
import { IRequestService } from 'vscode/vscode/vs/platform/request/common/request';
|
|
4
|
-
import { IDecorationsService } from 'vscode/vscode/vs/workbench/services/decorations/common/decorations';
|
|
5
|
-
import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing';
|
|
3
|
+
import { IRequestService } from 'vscode/vscode/vs/platform/request/common/request.service';
|
|
4
|
+
import { IDecorationsService } from 'vscode/vscode/vs/workbench/services/decorations/common/decorations.service';
|
|
5
|
+
import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing.service';
|
|
6
6
|
import { ITreeViewsDnDService } from 'vscode/vscode/vs/editor/common/services/treeViewsDndService';
|
|
7
|
-
import { ITreeViewsService } from 'vscode/vscode/vs/workbench/services/views/browser/treeViewsService';
|
|
7
|
+
import { ITreeViewsService } from 'vscode/vscode/vs/workbench/services/views/browser/treeViewsService.service';
|
|
8
8
|
import { TreeViewsDnDService } from 'vscode/vscode/vs/editor/common/services/treeViewsDnd';
|
|
9
|
-
import { IURLService } from 'vscode/vscode/vs/platform/url/common/url';
|
|
9
|
+
import { IURLService } from 'vscode/vscode/vs/platform/url/common/url.service';
|
|
10
10
|
import { JSONEditingService } from './vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js';
|
|
11
11
|
import { DecorationsService } from './vscode/src/vs/workbench/services/decorations/browser/decorationsService.js';
|
|
12
12
|
import { BrowserRequestService } from './vscode/src/vs/workbench/services/request/browser/requestService.js';
|
|
13
13
|
import { BrowserURLService } from './vscode/src/vs/workbench/services/url/browser/urlService.js';
|
|
14
14
|
import { TreeviewsService } from './vscode/src/vs/workbench/services/views/common/treeViewsService.js';
|
|
15
15
|
import { CanonicalUriService } from './vscode/src/vs/workbench/services/workspaces/common/canonicalUriService.js';
|
|
16
|
-
import { ICanonicalUriService } from 'vscode/vscode/vs/platform/workspace/common/canonicalUri';
|
|
17
|
-
import { IUserActivityService
|
|
18
|
-
import { IDownloadService } from 'vscode/vscode/vs/platform/download/common/download';
|
|
16
|
+
import { ICanonicalUriService } from 'vscode/vscode/vs/platform/workspace/common/canonicalUri.service';
|
|
17
|
+
import { IUserActivityService } from 'vscode/vscode/vs/workbench/services/userActivity/common/userActivityService.service';
|
|
18
|
+
import { IDownloadService } from 'vscode/vscode/vs/platform/download/common/download.service';
|
|
19
19
|
import { DownloadService } from './vscode/src/vs/platform/download/common/downloadService.js';
|
|
20
|
-
import {
|
|
21
|
-
import { IWorkingCopyFileService
|
|
22
|
-
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
|
|
23
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
24
|
-
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
20
|
+
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
|
|
21
|
+
import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service';
|
|
22
|
+
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
23
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
24
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
25
25
|
import { guessLocalUserHome } from './vscode/src/vs/workbench/services/path/browser/pathService.js';
|
|
26
|
+
import { AbstractPathService } from './vscode/src/vs/workbench/services/path/common/pathService.js';
|
|
27
|
+
import { UserActivityService } from './vscode/src/vs/workbench/services/userActivity/common/userActivityService.js';
|
|
28
|
+
import { WorkingCopyFileService } from './vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.js';
|
|
26
29
|
import { getEnvironmentOverride } from 'vscode/workbench';
|
|
27
30
|
|
|
28
31
|
let BrowserPathServiceOverride = class BrowserPathServiceOverride extends AbstractPathService {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-base-service-override",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -17,7 +17,15 @@
|
|
|
17
17
|
"main": "index.js",
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"default": "./index.js"
|
|
23
|
+
},
|
|
24
|
+
"./vscode/*": {
|
|
25
|
+
"default": "./vscode/src/*.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
20
28
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@4.
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@4.5.0"
|
|
22
30
|
}
|
|
23
31
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
|
|
3
3
|
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
4
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
5
|
-
import {
|
|
4
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
5
|
+
import { asTextOrError } from 'vscode/vscode/vs/platform/request/common/request';
|
|
6
|
+
import { IRequestService } from 'vscode/vscode/vs/platform/request/common/request.service';
|
|
6
7
|
|
|
7
8
|
let DownloadService = class DownloadService {
|
|
8
9
|
constructor(requestService, fileService) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { request } from '../../../base/parts/request/browser/request.js';
|
|
3
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
4
|
-
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
3
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
4
|
+
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
5
5
|
import { AbstractRequestService } from 'vscode/vscode/vs/platform/request/common/request';
|
|
6
6
|
|
|
7
7
|
let RequestService = class RequestService extends AbstractRequestService {
|
|
@@ -6,10 +6,11 @@ import { Queue } from 'vscode/vscode/vs/base/common/async';
|
|
|
6
6
|
import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
|
|
7
7
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
8
8
|
import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
|
|
9
|
-
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
10
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
9
|
+
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
10
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
11
11
|
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
12
|
-
import { JSONEditingError } from '
|
|
12
|
+
import { JSONEditingError } from './jsonEditing.js';
|
|
13
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
13
14
|
|
|
14
15
|
let JSONEditingService = class JSONEditingService {
|
|
15
16
|
constructor(fileService, textModelResolverService, textFileService) {
|
|
@@ -2,18 +2,18 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
|
2
2
|
import { DebounceEmitter, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
3
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
4
|
import { TernarySearchTree } from 'vscode/vscode/vs/base/common/ternarySearchTree';
|
|
5
|
-
import {
|
|
5
|
+
import { DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { isThenable } from 'vscode/vscode/vs/base/common/async';
|
|
7
7
|
import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
|
|
8
8
|
import { createCSSRule, asCSSPropertyValue, removeCSSRulesContainingSelector, createStyleSheet } from 'vscode/vscode/vs/base/browser/dom';
|
|
9
|
-
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
9
|
+
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
|
|
10
10
|
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
11
11
|
import { isFalsyOrWhitespace } from 'vscode/vscode/vs/base/common/strings';
|
|
12
12
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
13
13
|
import { isCancellationError } from 'vscode/vscode/vs/base/common/errors';
|
|
14
14
|
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
15
15
|
import { hash } from 'vscode/vscode/vs/base/common/hash';
|
|
16
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
16
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
17
17
|
import { distinct, asArray } from 'vscode/vscode/vs/base/common/arrays';
|
|
18
18
|
import { asCssVariable } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
19
19
|
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
2
|
-
import '
|
|
3
|
-
import { AbstractPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
|
|
2
|
+
import { AbstractPathService } from '../common/pathService.js';
|
|
4
3
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
-
import 'vscode/vscode/vs/nls';
|
|
6
|
-
import 'vscode/vscode/vs/base/common/path';
|
|
7
4
|
import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
|
|
8
|
-
import 'vscode/vscode/vs/base/common/strings';
|
|
9
5
|
import { dirname } from 'vscode/vscode/vs/base/common/resources';
|
|
10
|
-
import 'vscode/vscode/vs/base/common/network';
|
|
11
6
|
|
|
12
7
|
function guessLocalUserHome(environmentService, contextService) {
|
|
13
8
|
const workspace = contextService.getWorkspace();
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { isValidBasename } from 'vscode/vscode/vs/base/common/extpath';
|
|
3
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
4
|
+
import { win32, posix } from 'vscode/vscode/vs/base/common/path';
|
|
5
|
+
import { OS } from 'vscode/vscode/vs/base/common/platform';
|
|
6
|
+
import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
7
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
8
|
+
import { getVirtualWorkspaceScheme } from 'vscode/vscode/vs/platform/workspace/common/virtualWorkspace';
|
|
9
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
10
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
11
|
+
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
12
|
+
|
|
13
|
+
var AbstractPathService_1;
|
|
14
|
+
let AbstractPathService = AbstractPathService_1 = class AbstractPathService {
|
|
15
|
+
constructor(localUserHome, remoteAgentService, environmentService, contextService) {
|
|
16
|
+
this.localUserHome = localUserHome;
|
|
17
|
+
this.remoteAgentService = remoteAgentService;
|
|
18
|
+
this.environmentService = environmentService;
|
|
19
|
+
this.contextService = contextService;
|
|
20
|
+
this.resolveOS = (async () => {
|
|
21
|
+
const env = await this.remoteAgentService.getEnvironment();
|
|
22
|
+
return env?.os || OS;
|
|
23
|
+
})();
|
|
24
|
+
this.resolveUserHome = (async () => {
|
|
25
|
+
const env = await this.remoteAgentService.getEnvironment();
|
|
26
|
+
const userHome = this.maybeUnresolvedUserHome = env?.userHome ?? localUserHome;
|
|
27
|
+
return userHome;
|
|
28
|
+
})();
|
|
29
|
+
}
|
|
30
|
+
hasValidBasename(resource, arg2, basename) {
|
|
31
|
+
if (typeof arg2 === 'string' || typeof arg2 === 'undefined') {
|
|
32
|
+
return this.resolveOS.then(os => this.doHasValidBasename(resource, os, arg2));
|
|
33
|
+
}
|
|
34
|
+
return this.doHasValidBasename(resource, arg2, basename);
|
|
35
|
+
}
|
|
36
|
+
doHasValidBasename(resource, os, name) {
|
|
37
|
+
if (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote) {
|
|
38
|
+
return isValidBasename(name ?? basename(resource), os === 1 );
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
get defaultUriScheme() {
|
|
43
|
+
return AbstractPathService_1.findDefaultUriScheme(this.environmentService, this.contextService);
|
|
44
|
+
}
|
|
45
|
+
static findDefaultUriScheme(environmentService, contextService) {
|
|
46
|
+
if (environmentService.remoteAuthority) {
|
|
47
|
+
return Schemas.vscodeRemote;
|
|
48
|
+
}
|
|
49
|
+
const virtualWorkspace = getVirtualWorkspaceScheme(contextService.getWorkspace());
|
|
50
|
+
if (virtualWorkspace) {
|
|
51
|
+
return virtualWorkspace;
|
|
52
|
+
}
|
|
53
|
+
const firstFolder = contextService.getWorkspace().folders[0];
|
|
54
|
+
if (firstFolder) {
|
|
55
|
+
return firstFolder.uri.scheme;
|
|
56
|
+
}
|
|
57
|
+
const configuration = contextService.getWorkspace().configuration;
|
|
58
|
+
if (configuration) {
|
|
59
|
+
return configuration.scheme;
|
|
60
|
+
}
|
|
61
|
+
return Schemas.file;
|
|
62
|
+
}
|
|
63
|
+
userHome(options) {
|
|
64
|
+
return options?.preferLocal ? this.localUserHome : this.resolveUserHome;
|
|
65
|
+
}
|
|
66
|
+
get resolvedUserHome() {
|
|
67
|
+
return this.maybeUnresolvedUserHome;
|
|
68
|
+
}
|
|
69
|
+
get path() {
|
|
70
|
+
return this.resolveOS.then(os => {
|
|
71
|
+
return os === 1 ?
|
|
72
|
+
win32 :
|
|
73
|
+
posix;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async fileURI(_path) {
|
|
77
|
+
let authority = '';
|
|
78
|
+
const os = await this.resolveOS;
|
|
79
|
+
if (os === 1 ) {
|
|
80
|
+
_path = _path.replace(/\\/g, '/');
|
|
81
|
+
}
|
|
82
|
+
if (_path[0] === '/' && _path[1] === '/') {
|
|
83
|
+
const idx = _path.indexOf('/', 2);
|
|
84
|
+
if (idx === -1) {
|
|
85
|
+
authority = _path.substring(2);
|
|
86
|
+
_path = '/';
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
authority = _path.substring(2, idx);
|
|
90
|
+
_path = _path.substring(idx) || '/';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return ( URI.from({
|
|
94
|
+
scheme: Schemas.file,
|
|
95
|
+
authority,
|
|
96
|
+
path: _path,
|
|
97
|
+
query: '',
|
|
98
|
+
fragment: ''
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
AbstractPathService = AbstractPathService_1 = ( __decorate([
|
|
103
|
+
( __param(1, IRemoteAgentService)),
|
|
104
|
+
( __param(2, IWorkbenchEnvironmentService)),
|
|
105
|
+
( __param(3, IWorkspaceContextService))
|
|
106
|
+
], AbstractPathService));
|
|
107
|
+
|
|
108
|
+
export { AbstractPathService };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
3
|
-
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
2
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
3
|
+
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
4
4
|
import { RequestChannelClient } from '../../../../platform/request/common/requestIpc.js';
|
|
5
|
-
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
|
|
5
|
+
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
6
6
|
import { RequestService } from '../../../../platform/request/browser/requestService.js';
|
|
7
7
|
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
8
8
|
|
|
@@ -2,10 +2,10 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
|
2
2
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
3
3
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
4
4
|
import { AbstractURLService } from '../../../../platform/url/common/urlService.js';
|
|
5
|
-
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
|
|
6
|
-
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
5
|
+
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService.service';
|
|
6
|
+
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
|
|
7
7
|
import { matchesScheme } from 'vscode/vscode/vs/base/common/network';
|
|
8
|
-
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
|
|
8
|
+
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
9
9
|
|
|
10
10
|
class BrowserURLOpener {
|
|
11
11
|
constructor(urlService, productService) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class UserActivityRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.todo = [];
|
|
4
|
+
this.add = (ctor) => {
|
|
5
|
+
this.todo.push(ctor);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
take(userActivityService, instantiation) {
|
|
9
|
+
this.add = ctor => instantiation.createInstance(ctor, userActivityService);
|
|
10
|
+
this.todo.forEach(this.add);
|
|
11
|
+
this.todo = [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const userActivityRegistry = ( new UserActivityRegistry());
|
|
15
|
+
|
|
16
|
+
export { userActivityRegistry };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { RunOnceScheduler, runWhenGlobalIdle } from 'vscode/vscode/vs/base/common/async';
|
|
3
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
+
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
+
import { userActivityRegistry } from './userActivityRegistry.js';
|
|
7
|
+
|
|
8
|
+
let UserActivityService = class UserActivityService extends Disposable {
|
|
9
|
+
constructor(instantiationService) {
|
|
10
|
+
super();
|
|
11
|
+
this.markInactive = this._register(( new RunOnceScheduler(() => {
|
|
12
|
+
this.isActive = false;
|
|
13
|
+
this.changeEmitter.fire(false);
|
|
14
|
+
}, 10_000)));
|
|
15
|
+
this.changeEmitter = this._register(( new Emitter()));
|
|
16
|
+
this.active = 0;
|
|
17
|
+
this.isActive = true;
|
|
18
|
+
this.onDidChangeIsActive = this.changeEmitter.event;
|
|
19
|
+
this._register(runWhenGlobalIdle(() => userActivityRegistry.take(this, instantiationService)));
|
|
20
|
+
}
|
|
21
|
+
markActive() {
|
|
22
|
+
if (++this.active === 1) {
|
|
23
|
+
this.isActive = true;
|
|
24
|
+
this.changeEmitter.fire(true);
|
|
25
|
+
this.markInactive.cancel();
|
|
26
|
+
}
|
|
27
|
+
return toDisposable(() => {
|
|
28
|
+
if (--this.active === 0) {
|
|
29
|
+
this.markInactive.schedule();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
UserActivityService = ( __decorate([
|
|
35
|
+
( __param(0, IInstantiationService))
|
|
36
|
+
], UserActivityService));
|
|
37
|
+
|
|
38
|
+
export { UserActivityService };
|
package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopySaveParticipant.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { raceCancellation } from 'vscode/vscode/vs/base/common/async';
|
|
4
|
+
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
5
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
6
|
+
import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
|
|
7
|
+
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { insert } from 'vscode/vscode/vs/base/common/arrays';
|
|
9
|
+
|
|
10
|
+
let StoredFileWorkingCopySaveParticipant = class StoredFileWorkingCopySaveParticipant extends Disposable {
|
|
11
|
+
get length() { return this.saveParticipants.length; }
|
|
12
|
+
constructor(progressService, logService) {
|
|
13
|
+
super();
|
|
14
|
+
this.progressService = progressService;
|
|
15
|
+
this.logService = logService;
|
|
16
|
+
this.saveParticipants = [];
|
|
17
|
+
}
|
|
18
|
+
addSaveParticipant(participant) {
|
|
19
|
+
const remove = insert(this.saveParticipants, participant);
|
|
20
|
+
return toDisposable(() => remove());
|
|
21
|
+
}
|
|
22
|
+
participate(workingCopy, context, token) {
|
|
23
|
+
const cts = ( new CancellationTokenSource(token));
|
|
24
|
+
return this.progressService.withProgress({
|
|
25
|
+
title: ( localizeWithPath(
|
|
26
|
+
'vs/workbench/services/workingCopy/common/storedFileWorkingCopySaveParticipant',
|
|
27
|
+
'saveParticipants',
|
|
28
|
+
"Saving '{0}'",
|
|
29
|
+
workingCopy.name
|
|
30
|
+
)),
|
|
31
|
+
location: 15 ,
|
|
32
|
+
cancellable: true,
|
|
33
|
+
delay: workingCopy.isDirty() ? 3000 : 5000
|
|
34
|
+
}, async (progress) => {
|
|
35
|
+
workingCopy.model?.pushStackElement();
|
|
36
|
+
for (const saveParticipant of this.saveParticipants) {
|
|
37
|
+
if (cts.token.isCancellationRequested || workingCopy.isDisposed()) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const promise = saveParticipant.participate(workingCopy, context, progress, cts.token);
|
|
42
|
+
await raceCancellation(promise, cts.token);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
this.logService.warn(err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
workingCopy.model?.pushStackElement();
|
|
49
|
+
cts.dispose();
|
|
50
|
+
}, () => {
|
|
51
|
+
cts.dispose(true);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
dispose() {
|
|
55
|
+
this.saveParticipants.splice(0, this.saveParticipants.length);
|
|
56
|
+
super.dispose();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
StoredFileWorkingCopySaveParticipant = ( __decorate([
|
|
60
|
+
( __param(0, IProgressService)),
|
|
61
|
+
( __param(1, ILogService))
|
|
62
|
+
], StoredFileWorkingCopySaveParticipant));
|
|
63
|
+
|
|
64
|
+
export { StoredFileWorkingCopySaveParticipant };
|
package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
3
|
+
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
5
|
+
import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
|
|
6
|
+
|
|
7
|
+
let WorkingCopyFileOperationParticipant = class WorkingCopyFileOperationParticipant extends Disposable {
|
|
8
|
+
constructor(logService, configurationService) {
|
|
9
|
+
super();
|
|
10
|
+
this.logService = logService;
|
|
11
|
+
this.configurationService = configurationService;
|
|
12
|
+
this.participants = ( new LinkedList());
|
|
13
|
+
}
|
|
14
|
+
addFileOperationParticipant(participant) {
|
|
15
|
+
const remove = this.participants.push(participant);
|
|
16
|
+
return toDisposable(() => remove());
|
|
17
|
+
}
|
|
18
|
+
async participate(files, operation, undoInfo, token) {
|
|
19
|
+
const timeout = this.configurationService.getValue('files.participants.timeout');
|
|
20
|
+
if (typeof timeout !== 'number' || timeout <= 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const participant of this.participants) {
|
|
24
|
+
try {
|
|
25
|
+
await participant.participate(files, operation, undoInfo, timeout, token);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
this.logService.warn(err);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.participants.clear();
|
|
34
|
+
super.dispose();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
WorkingCopyFileOperationParticipant = ( __decorate([
|
|
38
|
+
( __param(0, ILogService)),
|
|
39
|
+
( __param(1, IConfigurationService))
|
|
40
|
+
], WorkingCopyFileOperationParticipant));
|
|
41
|
+
|
|
42
|
+
export { WorkingCopyFileOperationParticipant };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
3
|
+
import { AsyncEmitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
+
import { Promises } from 'vscode/vscode/vs/base/common/async';
|
|
5
|
+
import { insert } from 'vscode/vscode/vs/base/common/arrays';
|
|
6
|
+
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
8
|
+
import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
|
|
9
|
+
import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service';
|
|
10
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
11
|
+
import { WorkingCopyFileOperationParticipant } from './workingCopyFileOperationParticipant.js';
|
|
12
|
+
import { StoredFileWorkingCopySaveParticipant } from './storedFileWorkingCopySaveParticipant.js';
|
|
13
|
+
|
|
14
|
+
let WorkingCopyFileService = class WorkingCopyFileService extends Disposable {
|
|
15
|
+
constructor(fileService, workingCopyService, instantiationService, uriIdentityService) {
|
|
16
|
+
super();
|
|
17
|
+
this.fileService = fileService;
|
|
18
|
+
this.workingCopyService = workingCopyService;
|
|
19
|
+
this.instantiationService = instantiationService;
|
|
20
|
+
this.uriIdentityService = uriIdentityService;
|
|
21
|
+
this._onWillRunWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
22
|
+
this.onWillRunWorkingCopyFileOperation = this._onWillRunWorkingCopyFileOperation.event;
|
|
23
|
+
this._onDidFailWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
24
|
+
this.onDidFailWorkingCopyFileOperation = this._onDidFailWorkingCopyFileOperation.event;
|
|
25
|
+
this._onDidRunWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
26
|
+
this.onDidRunWorkingCopyFileOperation = this._onDidRunWorkingCopyFileOperation.event;
|
|
27
|
+
this.correlationIds = 0;
|
|
28
|
+
this.fileOperationParticipants = this._register(this.instantiationService.createInstance(WorkingCopyFileOperationParticipant));
|
|
29
|
+
this.saveParticipants = this._register(this.instantiationService.createInstance(StoredFileWorkingCopySaveParticipant));
|
|
30
|
+
this.workingCopyProviders = [];
|
|
31
|
+
this._register(this.registerWorkingCopyProvider(resource => {
|
|
32
|
+
return this.workingCopyService.workingCopies.filter(workingCopy => {
|
|
33
|
+
if (this.fileService.hasProvider(resource)) {
|
|
34
|
+
return this.uriIdentityService.extUri.isEqualOrParent(workingCopy.resource, resource);
|
|
35
|
+
}
|
|
36
|
+
return this.uriIdentityService.extUri.isEqual(workingCopy.resource, resource);
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
create(operations, token, undoInfo) {
|
|
41
|
+
return this.doCreateFileOrFolder(operations, true, token, undoInfo);
|
|
42
|
+
}
|
|
43
|
+
createFolder(operations, token, undoInfo) {
|
|
44
|
+
return this.doCreateFileOrFolder(operations, false, token, undoInfo);
|
|
45
|
+
}
|
|
46
|
+
async doCreateFileOrFolder(operations, isFile, token, undoInfo) {
|
|
47
|
+
if (operations.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
if (isFile) {
|
|
51
|
+
const validateCreates = await Promises.settled(( operations.map(
|
|
52
|
+
operation => this.fileService.canCreateFile(operation.resource, { overwrite: operation.overwrite })
|
|
53
|
+
)));
|
|
54
|
+
const error = validateCreates.find(validateCreate => validateCreate instanceof Error);
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const files = ( operations.map(operation => ({ target: operation.resource })));
|
|
60
|
+
await this.runFileOperationParticipants(files, 0 , undoInfo, token);
|
|
61
|
+
const event = { correlationId: this.correlationIds++, operation: 0 , files };
|
|
62
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
63
|
+
let stats;
|
|
64
|
+
try {
|
|
65
|
+
if (isFile) {
|
|
66
|
+
stats = await Promises.settled(( operations.map(
|
|
67
|
+
operation => this.fileService.createFile(operation.resource, operation.contents, { overwrite: operation.overwrite })
|
|
68
|
+
)));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
stats = await Promises.settled(( operations.map(operation => this.fileService.createFolder(operation.resource))));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
79
|
+
return stats;
|
|
80
|
+
}
|
|
81
|
+
async move(operations, token, undoInfo) {
|
|
82
|
+
return this.doMoveOrCopy(operations, true, token, undoInfo);
|
|
83
|
+
}
|
|
84
|
+
async copy(operations, token, undoInfo) {
|
|
85
|
+
return this.doMoveOrCopy(operations, false, token, undoInfo);
|
|
86
|
+
}
|
|
87
|
+
async doMoveOrCopy(operations, move, token, undoInfo) {
|
|
88
|
+
const stats = [];
|
|
89
|
+
for (const { file: { source, target }, overwrite } of operations) {
|
|
90
|
+
const validateMoveOrCopy = await (move ? this.fileService.canMove(source, target, overwrite) : this.fileService.canCopy(source, target, overwrite));
|
|
91
|
+
if (validateMoveOrCopy instanceof Error) {
|
|
92
|
+
throw validateMoveOrCopy;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const files = ( operations.map(o => o.file));
|
|
96
|
+
await this.runFileOperationParticipants(files, move ? 2 : 3 , undoInfo, token);
|
|
97
|
+
const event = { correlationId: this.correlationIds++, operation: move ? 2 : 3 , files };
|
|
98
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
99
|
+
try {
|
|
100
|
+
for (const { file: { source, target }, overwrite } of operations) {
|
|
101
|
+
if (!this.uriIdentityService.extUri.isEqual(source, target)) {
|
|
102
|
+
const dirtyWorkingCopies = (move ? [...this.getDirty(source), ...this.getDirty(target)] : this.getDirty(target));
|
|
103
|
+
await Promises.settled(( dirtyWorkingCopies.map(dirtyWorkingCopy => dirtyWorkingCopy.revert({ soft: true }))));
|
|
104
|
+
}
|
|
105
|
+
if (move) {
|
|
106
|
+
stats.push(await this.fileService.move(source, target, overwrite));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
stats.push(await this.fileService.copy(source, target, overwrite));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
118
|
+
return stats;
|
|
119
|
+
}
|
|
120
|
+
async delete(operations, token, undoInfo) {
|
|
121
|
+
for (const operation of operations) {
|
|
122
|
+
const validateDelete = await this.fileService.canDelete(operation.resource, { recursive: operation.recursive, useTrash: operation.useTrash });
|
|
123
|
+
if (validateDelete instanceof Error) {
|
|
124
|
+
throw validateDelete;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const files = ( operations.map(operation => ({ target: operation.resource })));
|
|
128
|
+
await this.runFileOperationParticipants(files, 1 , undoInfo, token);
|
|
129
|
+
const event = { correlationId: this.correlationIds++, operation: 1 , files };
|
|
130
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
131
|
+
for (const operation of operations) {
|
|
132
|
+
const dirtyWorkingCopies = this.getDirty(operation.resource);
|
|
133
|
+
await Promises.settled(( dirtyWorkingCopies.map(dirtyWorkingCopy => dirtyWorkingCopy.revert({ soft: true }))));
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
for (const operation of operations) {
|
|
137
|
+
await this.fileService.del(operation.resource, { recursive: operation.recursive, useTrash: operation.useTrash });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
145
|
+
}
|
|
146
|
+
addFileOperationParticipant(participant) {
|
|
147
|
+
return this.fileOperationParticipants.addFileOperationParticipant(participant);
|
|
148
|
+
}
|
|
149
|
+
runFileOperationParticipants(files, operation, undoInfo, token) {
|
|
150
|
+
return this.fileOperationParticipants.participate(files, operation, undoInfo, token);
|
|
151
|
+
}
|
|
152
|
+
get hasSaveParticipants() { return this.saveParticipants.length > 0; }
|
|
153
|
+
addSaveParticipant(participant) {
|
|
154
|
+
return this.saveParticipants.addSaveParticipant(participant);
|
|
155
|
+
}
|
|
156
|
+
runSaveParticipants(workingCopy, context, token) {
|
|
157
|
+
return this.saveParticipants.participate(workingCopy, context, token);
|
|
158
|
+
}
|
|
159
|
+
registerWorkingCopyProvider(provider) {
|
|
160
|
+
const remove = insert(this.workingCopyProviders, provider);
|
|
161
|
+
return toDisposable(remove);
|
|
162
|
+
}
|
|
163
|
+
getDirty(resource) {
|
|
164
|
+
const dirtyWorkingCopies = ( new Set());
|
|
165
|
+
for (const provider of this.workingCopyProviders) {
|
|
166
|
+
for (const workingCopy of provider(resource)) {
|
|
167
|
+
if (workingCopy.isDirty()) {
|
|
168
|
+
dirtyWorkingCopies.add(workingCopy);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return Array.from(dirtyWorkingCopies);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
WorkingCopyFileService = ( __decorate([
|
|
176
|
+
( __param(0, IFileService)),
|
|
177
|
+
( __param(1, IWorkingCopyService)),
|
|
178
|
+
( __param(2, IInstantiationService)),
|
|
179
|
+
( __param(3, IUriIdentityService))
|
|
180
|
+
], WorkingCopyFileService));
|
|
181
|
+
|
|
182
|
+
export { WorkingCopyFileService };
|