@theia/navigator 1.77.0-next.57 → 1.77.0-next.63
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/lib/browser/navigator-container.d.ts.map +1 -1
- package/lib/browser/navigator-container.js +3 -0
- package/lib/browser/navigator-container.js.map +1 -1
- package/lib/browser/navigator-tree-compression-service.d.ts +9 -0
- package/lib/browser/navigator-tree-compression-service.d.ts.map +1 -0
- package/lib/browser/navigator-tree-compression-service.js +36 -0
- package/lib/browser/navigator-tree-compression-service.js.map +1 -0
- package/lib/browser/navigator-tree-compression-service.spec.d.ts +2 -0
- package/lib/browser/navigator-tree-compression-service.spec.d.ts.map +1 -0
- package/lib/browser/navigator-tree-compression-service.spec.js +56 -0
- package/lib/browser/navigator-tree-compression-service.spec.js.map +1 -0
- package/package.json +5 -5
- package/src/browser/navigator-container.ts +4 -1
- package/src/browser/navigator-tree-compression-service.spec.ts +63 -0
- package/src/browser/navigator-tree-compression-service.ts +31 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigator-container.d.ts","sourceRoot":"","sources":["../../src/browser/navigator-container.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"navigator-container.d.ts","sourceRoot":"","sources":["../../src/browser/navigator-container.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAA0B,SAAS,EAAoB,MAAM,yBAAyB,CAAC;AAI9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAKzD,eAAO,MAAM,oBAAoB,EAAI,SAMpC,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,GAAG,SAAS,CAYpF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,GAAG,mBAAmB,CAE3F"}
|
|
@@ -25,6 +25,7 @@ const navigator_model_1 = require("./navigator-model");
|
|
|
25
25
|
const navigator_widget_1 = require("./navigator-widget");
|
|
26
26
|
const navigator_contribution_1 = require("./navigator-contribution");
|
|
27
27
|
const navigator_decorator_service_1 = require("./navigator-decorator-service");
|
|
28
|
+
const navigator_tree_compression_service_1 = require("./navigator-tree-compression-service");
|
|
28
29
|
exports.FILE_NAVIGATOR_PROPS = {
|
|
29
30
|
...browser_1.defaultTreeProps,
|
|
30
31
|
contextMenuPath: navigator_contribution_1.NAVIGATOR_CONTEXT_MENU,
|
|
@@ -40,6 +41,8 @@ function createFileNavigatorContainer(parent) {
|
|
|
40
41
|
decoratorService: navigator_decorator_service_1.NavigatorDecoratorService,
|
|
41
42
|
props: exports.FILE_NAVIGATOR_PROPS,
|
|
42
43
|
});
|
|
44
|
+
child.bind(navigator_tree_compression_service_1.FileNavigatorTreeCompressionService).toSelf().inSingletonScope();
|
|
45
|
+
child.rebind(browser_1.TreeCompressionService).toService(navigator_tree_compression_service_1.FileNavigatorTreeCompressionService);
|
|
43
46
|
return child;
|
|
44
47
|
}
|
|
45
48
|
function createFileNavigatorWidget(parent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigator-container.js","sourceRoot":"","sources":["../../src/browser/navigator-container.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;
|
|
1
|
+
{"version":3,"file":"navigator-container.js","sourceRoot":"","sources":["../../src/browser/navigator-container.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAoBhF,oEAYC;AAED,8DAEC;AAjCD,qDAA8F;AAC9F,2DAAwE;AACxE,qDAAqD;AACrD,uDAAuD;AACvD,yDAAyD;AACzD,qEAAkE;AAClE,+EAA0E;AAC1E,6FAA2F;AAE9E,QAAA,oBAAoB,GAAc;IAC3C,GAAG,0BAAgB;IACnB,eAAe,EAAE,+CAAsB;IACvC,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,eAAe,EAAE,IAAI;CACxB,CAAC;AAEF,SAAgB,4BAA4B,CAAC,MAA4B;IACrE,MAAM,KAAK,GAAG,IAAA,iCAAuB,EAAC,MAAM,EAAE;QAC1C,IAAI,EAAE,kCAAiB;QACvB,KAAK,EAAE,oCAAkB;QACzB,MAAM,EAAE,sCAAmB;QAC3B,gBAAgB,EAAE,uDAAyB;QAC3C,KAAK,EAAE,4BAAoB;KAC9B,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,CAAC,wEAAmC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC5E,KAAK,CAAC,MAAM,CAAC,gCAAsB,CAAC,CAAC,SAAS,CAAC,wEAAmC,CAAC,CAAC;IAEpF,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,yBAAyB,CAAC,MAA4B;IAClE,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,sCAAmB,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompressionParent, TreeCompressionService } from '@theia/core/lib/browser';
|
|
2
|
+
/**
|
|
3
|
+
* Does not compact the roots of a multi-root workspace with their folders, as VS Code does, so that
|
|
4
|
+
* the name of a root, which may be a path like `alice/app`, is not taken for a part of the compacted path.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileNavigatorTreeCompressionService extends TreeCompressionService {
|
|
7
|
+
isCompressionParent(node?: unknown): node is CompressionParent;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=navigator-tree-compression-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator-tree-compression-service.d.ts","sourceRoot":"","sources":["../../src/browser/navigator-tree-compression-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAIpF;;;GAGG;AACH,qBACa,mCAAoC,SAAQ,sBAAsB;IAElE,mBAAmB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,IAAI,iBAAiB;CAG1E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FileNavigatorTreeCompressionService = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const navigator_tree_1 = require("./navigator-tree");
|
|
23
|
+
/**
|
|
24
|
+
* Does not compact the roots of a multi-root workspace with their folders, as VS Code does, so that
|
|
25
|
+
* the name of a root, which may be a path like `alice/app`, is not taken for a part of the compacted path.
|
|
26
|
+
*/
|
|
27
|
+
let FileNavigatorTreeCompressionService = class FileNavigatorTreeCompressionService extends browser_1.TreeCompressionService {
|
|
28
|
+
isCompressionParent(node) {
|
|
29
|
+
return !navigator_tree_1.WorkspaceRootNode.is(node) && super.isCompressionParent(node);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.FileNavigatorTreeCompressionService = FileNavigatorTreeCompressionService;
|
|
33
|
+
exports.FileNavigatorTreeCompressionService = FileNavigatorTreeCompressionService = tslib_1.__decorate([
|
|
34
|
+
(0, inversify_1.injectable)()
|
|
35
|
+
], FileNavigatorTreeCompressionService);
|
|
36
|
+
//# sourceMappingURL=navigator-tree-compression-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator-tree-compression-service.js","sourceRoot":"","sources":["../../src/browser/navigator-tree-compression-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,qDAAoF;AACpF,4DAA0D;AAC1D,qDAAqD;AAErD;;;GAGG;AAEI,IAAM,mCAAmC,GAAzC,MAAM,mCAAoC,SAAQ,gCAAsB;IAElE,mBAAmB,CAAC,IAAc;QACvC,OAAO,CAAC,kCAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;CACJ,CAAA;AALY,kFAAmC;8CAAnC,mCAAmC;IAD/C,IAAA,sBAAU,GAAE;GACA,mCAAmC,CAK/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator-tree-compression-service.spec.d.ts","sourceRoot":"","sources":["../../src/browser/navigator-tree-compression-service.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const tslib_1 = require("tslib");
|
|
19
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
20
|
+
const disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
21
|
+
const chai_1 = require("chai");
|
|
22
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
23
|
+
const uri_1 = tslib_1.__importDefault(require("@theia/core/lib/common/uri"));
|
|
24
|
+
const files_1 = require("@theia/filesystem/lib/common/files");
|
|
25
|
+
const navigator_tree_1 = require("./navigator-tree");
|
|
26
|
+
const navigator_tree_compression_service_1 = require("./navigator-tree-compression-service");
|
|
27
|
+
disableJSDOM();
|
|
28
|
+
describe('FileNavigatorTreeCompressionService', () => {
|
|
29
|
+
const service = new navigator_tree_compression_service_1.FileNavigatorTreeCompressionService();
|
|
30
|
+
const dir = (uri, parent, visible = true) => {
|
|
31
|
+
const node = {
|
|
32
|
+
id: uri, uri: new uri_1.default(uri), fileStat: files_1.FileStat.dir(uri), name: new uri_1.default(uri).path.base,
|
|
33
|
+
parent, children: [], expanded: false, selected: false, visible
|
|
34
|
+
};
|
|
35
|
+
browser_1.CompositeTreeNode.addChild(parent, node);
|
|
36
|
+
return node;
|
|
37
|
+
};
|
|
38
|
+
it('does not compact the root of a multi-root workspace with its only folder', () => {
|
|
39
|
+
const workspace = navigator_tree_1.WorkspaceNode.createRoot('multi');
|
|
40
|
+
const root = dir('file:///alice/app', workspace);
|
|
41
|
+
const src = dir('file:///alice/app/src', root);
|
|
42
|
+
dir('file:///alice/app/src/main', src);
|
|
43
|
+
(0, chai_1.expect)(service.isCompressionParent(root)).to.be.false;
|
|
44
|
+
(0, chai_1.expect)(service.isCompressionChild(src)).to.be.false;
|
|
45
|
+
(0, chai_1.expect)(service.isCompressionParent(src)).to.be.true;
|
|
46
|
+
});
|
|
47
|
+
it('compacts the folders of a single-root workspace', () => {
|
|
48
|
+
const root = dir('file:///alice/app', navigator_tree_1.WorkspaceNode.createRoot(), false);
|
|
49
|
+
const src = dir('file:///alice/app/src', root);
|
|
50
|
+
const main = dir('file:///alice/app/src/main', src);
|
|
51
|
+
dir('file:///alice/app/src/main/ts', main);
|
|
52
|
+
(0, chai_1.expect)(service.isCompressionHead(src)).to.be.true;
|
|
53
|
+
(0, chai_1.expect)(service.isCompressionChild(main)).to.be.true;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=navigator-tree-compression-service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator-tree-compression-service.spec.js","sourceRoot":"","sources":["../../src/browser/navigator-tree-compression-service.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,8DAAiE;AACjE,MAAM,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AAEnC,+BAA8B;AAC9B,qDAA4D;AAC5D,6EAA6C;AAE7C,8DAA8D;AAC9D,qDAAiD;AACjD,6FAA2F;AAE3F,YAAY,EAAE,CAAC;AAEf,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IAEjD,MAAM,OAAO,GAAG,IAAI,wEAAmC,EAAE,CAAC;IAE1D,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,MAAyB,EAAE,OAAO,GAAG,IAAI,EAAW,EAAE;QAC5E,MAAM,IAAI,GAAY;YAClB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,aAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,gBAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,aAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI;YACrF,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;SAClE,CAAC;QACF,2BAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAChF,MAAM,SAAS,GAAG,8BAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACpD,MAAM,IAAI,GAAG,GAAG,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC/C,GAAG,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;QAEvC,IAAA,aAAM,EAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QACtD,IAAA,aAAM,EAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QACpD,IAAA,aAAM,EAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACvD,MAAM,IAAI,GAAG,GAAG,CAAC,mBAAmB,EAAE,8BAAa,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;QACzE,MAAM,GAAG,GAAG,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;QACpD,GAAG,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;QAE3C,IAAA,aAAM,EAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAClD,IAAA,aAAM,EAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/navigator",
|
|
3
|
-
"version": "1.77.0-next.
|
|
3
|
+
"version": "1.77.0-next.63+046af0812",
|
|
4
4
|
"description": "Theia - Navigator Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.77.0-next.
|
|
7
|
-
"@theia/filesystem": "1.77.0-next.
|
|
8
|
-
"@theia/workspace": "1.77.0-next.
|
|
6
|
+
"@theia/core": "1.77.0-next.63+046af0812",
|
|
7
|
+
"@theia/filesystem": "1.77.0-next.63+046af0812",
|
|
8
|
+
"@theia/workspace": "1.77.0-next.63+046af0812",
|
|
9
9
|
"minimatch": "^10.2.6",
|
|
10
10
|
"tslib": "^2.8.1"
|
|
11
11
|
},
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"nyc": {
|
|
52
52
|
"extends": "../../configs/nyc.json"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "046af0812516f46f2bf7ce3357cca0b672159b20"
|
|
55
55
|
}
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Container, interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { TreeProps, defaultTreeProps } from '@theia/core/lib/browser';
|
|
18
|
+
import { TreeCompressionService, TreeProps, defaultTreeProps } from '@theia/core/lib/browser';
|
|
19
19
|
import { createFileTreeContainer } from '@theia/filesystem/lib/browser';
|
|
20
20
|
import { FileNavigatorTree } from './navigator-tree';
|
|
21
21
|
import { FileNavigatorModel } from './navigator-model';
|
|
22
22
|
import { FileNavigatorWidget } from './navigator-widget';
|
|
23
23
|
import { NAVIGATOR_CONTEXT_MENU } from './navigator-contribution';
|
|
24
24
|
import { NavigatorDecoratorService } from './navigator-decorator-service';
|
|
25
|
+
import { FileNavigatorTreeCompressionService } from './navigator-tree-compression-service';
|
|
25
26
|
|
|
26
27
|
export const FILE_NAVIGATOR_PROPS = <TreeProps>{
|
|
27
28
|
...defaultTreeProps,
|
|
@@ -39,6 +40,8 @@ export function createFileNavigatorContainer(parent: interfaces.Container): Cont
|
|
|
39
40
|
decoratorService: NavigatorDecoratorService,
|
|
40
41
|
props: FILE_NAVIGATOR_PROPS,
|
|
41
42
|
});
|
|
43
|
+
child.bind(FileNavigatorTreeCompressionService).toSelf().inSingletonScope();
|
|
44
|
+
child.rebind(TreeCompressionService).toService(FileNavigatorTreeCompressionService);
|
|
42
45
|
|
|
43
46
|
return child;
|
|
44
47
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
+
const disableJSDOM = enableJSDOM();
|
|
19
|
+
|
|
20
|
+
import { expect } from 'chai';
|
|
21
|
+
import { CompositeTreeNode } from '@theia/core/lib/browser';
|
|
22
|
+
import URI from '@theia/core/lib/common/uri';
|
|
23
|
+
import { DirNode } from '@theia/filesystem/lib/browser';
|
|
24
|
+
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
25
|
+
import { WorkspaceNode } from './navigator-tree';
|
|
26
|
+
import { FileNavigatorTreeCompressionService } from './navigator-tree-compression-service';
|
|
27
|
+
|
|
28
|
+
disableJSDOM();
|
|
29
|
+
|
|
30
|
+
describe('FileNavigatorTreeCompressionService', () => {
|
|
31
|
+
|
|
32
|
+
const service = new FileNavigatorTreeCompressionService();
|
|
33
|
+
|
|
34
|
+
const dir = (uri: string, parent: CompositeTreeNode, visible = true): DirNode => {
|
|
35
|
+
const node: DirNode = {
|
|
36
|
+
id: uri, uri: new URI(uri), fileStat: FileStat.dir(uri), name: new URI(uri).path.base,
|
|
37
|
+
parent, children: [], expanded: false, selected: false, visible
|
|
38
|
+
};
|
|
39
|
+
CompositeTreeNode.addChild(parent, node);
|
|
40
|
+
return node;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
it('does not compact the root of a multi-root workspace with its only folder', () => {
|
|
44
|
+
const workspace = WorkspaceNode.createRoot('multi');
|
|
45
|
+
const root = dir('file:///alice/app', workspace);
|
|
46
|
+
const src = dir('file:///alice/app/src', root);
|
|
47
|
+
dir('file:///alice/app/src/main', src);
|
|
48
|
+
|
|
49
|
+
expect(service.isCompressionParent(root)).to.be.false;
|
|
50
|
+
expect(service.isCompressionChild(src)).to.be.false;
|
|
51
|
+
expect(service.isCompressionParent(src)).to.be.true;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('compacts the folders of a single-root workspace', () => {
|
|
55
|
+
const root = dir('file:///alice/app', WorkspaceNode.createRoot(), false);
|
|
56
|
+
const src = dir('file:///alice/app/src', root);
|
|
57
|
+
const main = dir('file:///alice/app/src/main', src);
|
|
58
|
+
dir('file:///alice/app/src/main/ts', main);
|
|
59
|
+
|
|
60
|
+
expect(service.isCompressionHead(src)).to.be.true;
|
|
61
|
+
expect(service.isCompressionChild(main)).to.be.true;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CompressionParent, TreeCompressionService } from '@theia/core/lib/browser';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { WorkspaceRootNode } from './navigator-tree';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Does not compact the roots of a multi-root workspace with their folders, as VS Code does, so that
|
|
23
|
+
* the name of a root, which may be a path like `alice/app`, is not taken for a part of the compacted path.
|
|
24
|
+
*/
|
|
25
|
+
@injectable()
|
|
26
|
+
export class FileNavigatorTreeCompressionService extends TreeCompressionService {
|
|
27
|
+
|
|
28
|
+
override isCompressionParent(node?: unknown): node is CompressionParent {
|
|
29
|
+
return !WorkspaceRootNode.is(node) && super.isCompressionParent(node);
|
|
30
|
+
}
|
|
31
|
+
}
|