mirror of https://github.com/opensumi/core
feat: support copy relative path from link files (#4367)
* feat: support copy relative path from link files * chore: add @opensumi/ide-utils dependency * chore: reorder @opensumi/ide-utils dependency * chore: update test coverage exclusions for notebook module * fix: handle leading separators in TreeNode paths and use fsPath for URIs
This commit is contained in:
parent
7d522955ff
commit
2aba876807
|
@ -17,8 +17,9 @@ const baseConfig = {
|
||||||
// 部分contribution文件为-contribution结尾
|
// 部分contribution文件为-contribution结尾
|
||||||
'!packages/**/*-contribution.ts',
|
'!packages/**/*-contribution.ts',
|
||||||
'!packages/startup/**/*.ts',
|
'!packages/startup/**/*.ts',
|
||||||
// Test 功能暂未完成
|
// Test, Notebook 模块暂不覆盖
|
||||||
'!packages/testing/**/*.ts',
|
'!packages/testing/**/*.ts',
|
||||||
|
'!packages/notebook/**/*.ts',
|
||||||
// CLI 不需要测试
|
// CLI 不需要测试
|
||||||
'!packages/remote-cli/**/*.ts',
|
'!packages/remote-cli/**/*.ts',
|
||||||
'!packages/core-electron-main/**/*.ts',
|
'!packages/core-electron-main/**/*.ts',
|
||||||
|
|
|
@ -236,9 +236,11 @@ export class TreeNode implements ITreeNode {
|
||||||
get path(): string {
|
get path(): string {
|
||||||
if (!this._path) {
|
if (!this._path) {
|
||||||
if (!this.parent) {
|
if (!this.parent) {
|
||||||
this._path = new Path(`${Path.separator}${this.name}`).toString();
|
this._path = this.name.startsWith(Path.separator) ? this.name : `${Path.separator}${this.name}`;
|
||||||
} else {
|
} else {
|
||||||
this._path = new Path(this.parent.path).join(this.name).toString();
|
this._path = this.name.startsWith(Path.separator)
|
||||||
|
? `${this.parent.path}${this.name}`
|
||||||
|
: `${this.parent.path}${Path.separator}${this.name}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._path;
|
return this._path;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
"@opensumi/ide-overlay": "workspace:*",
|
"@opensumi/ide-overlay": "workspace:*",
|
||||||
"@opensumi/ide-terminal-next": "workspace:*",
|
"@opensumi/ide-terminal-next": "workspace:*",
|
||||||
"@opensumi/ide-theme": "workspace:*",
|
"@opensumi/ide-theme": "workspace:*",
|
||||||
|
"@opensumi/ide-utils": "workspace:*",
|
||||||
"@opensumi/ide-workspace": "workspace:*",
|
"@opensumi/ide-workspace": "workspace:*",
|
||||||
"@opensumi/ide-workspace-edit": "workspace:*"
|
"@opensumi/ide-workspace-edit": "workspace:*"
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ import { EXPLORER_CONTAINER_ID } from '@opensumi/ide-explorer/lib/browser/explor
|
||||||
import { IMainLayoutService, IViewsRegistry, MainLayoutContribution } from '@opensumi/ide-main-layout';
|
import { IMainLayoutService, IViewsRegistry, MainLayoutContribution } from '@opensumi/ide-main-layout';
|
||||||
import { ViewContentGroups } from '@opensumi/ide-main-layout/lib/browser/views-registry';
|
import { ViewContentGroups } from '@opensumi/ide-main-layout/lib/browser/views-registry';
|
||||||
import { IOpenDialogOptions, ISaveDialogOptions, IWindowDialogService } from '@opensumi/ide-overlay';
|
import { IOpenDialogOptions, ISaveDialogOptions, IWindowDialogService } from '@opensumi/ide-overlay';
|
||||||
|
import { Path } from '@opensumi/ide-utils/lib/path';
|
||||||
import { IWorkspaceService, UNTITLED_WORKSPACE } from '@opensumi/ide-workspace';
|
import { IWorkspaceService, UNTITLED_WORKSPACE } from '@opensumi/ide-workspace';
|
||||||
|
|
||||||
import { IFileTreeService, PasteTypes, RESOURCE_VIEW_ID } from '../common';
|
import { IFileTreeService, PasteTypes, RESOURCE_VIEW_ID } from '../common';
|
||||||
|
@ -778,9 +779,15 @@ export class FileTreeContribution
|
||||||
}
|
}
|
||||||
if (uri.scheme === DIFF_SCHEME) {
|
if (uri.scheme === DIFF_SCHEME) {
|
||||||
const query = uri.getParsedQuery();
|
const query = uri.getParsedQuery();
|
||||||
// 需要file scheme才能与工作区计算相对路径
|
|
||||||
uri = new URI(query.modified).withScheme('file');
|
uri = new URI(query.modified).withScheme('file');
|
||||||
}
|
}
|
||||||
|
const node = this.fileTreeService.getNodeByPathOrUri(uri);
|
||||||
|
if (node) {
|
||||||
|
if (node.filestat.isInSymbolicDirectory) {
|
||||||
|
// 软链接文件需要通过直接通过文件树 Path 获取
|
||||||
|
return await this.clipboardService.writeText(node.path.split(Path.separator).slice(2).join(Path.separator));
|
||||||
|
}
|
||||||
|
}
|
||||||
let rootUri: URI;
|
let rootUri: URI;
|
||||||
if (this.fileTreeService.isMultipleWorkspace) {
|
if (this.fileTreeService.isMultipleWorkspace) {
|
||||||
// 多工作区额外处理
|
// 多工作区额外处理
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class EditorFile extends TreeNode {
|
||||||
public dirty: boolean = false,
|
public dirty: boolean = false,
|
||||||
parent: EditorFileGroup | undefined,
|
parent: EditorFileGroup | undefined,
|
||||||
) {
|
) {
|
||||||
super(tree as ITree, parent, undefined, { name: `${resource.uri.toString()}` });
|
super(tree as ITree, parent, undefined, { name: `${resource.uri.codeUri.fsPath.toString()}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
get displayName() {
|
get displayName() {
|
||||||
|
|
|
@ -127,16 +127,16 @@ export class OpenedEditorService extends Tree {
|
||||||
.join(groupName)
|
.join(groupName)
|
||||||
.join(
|
.join(
|
||||||
resource && (resource as IResource).uri
|
resource && (resource as IResource).uri
|
||||||
? (resource as IResource).uri.toString()
|
? (resource as IResource).uri.codeUri.fsPath
|
||||||
: (resource as URI).toString(),
|
: (resource as URI).codeUri.fsPath,
|
||||||
)
|
)
|
||||||
.toString();
|
.toString();
|
||||||
} else {
|
} else {
|
||||||
path = new Path(path)
|
path = new Path(path)
|
||||||
.join(
|
.join(
|
||||||
resource && (resource as IResource).uri
|
resource && (resource as IResource).uri
|
||||||
? (resource as IResource).uri.toString()
|
? (resource as IResource).uri.codeUri.fsPath
|
||||||
: (resource as URI).toString(),
|
: (resource as URI).codeUri.fsPath,
|
||||||
)
|
)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3731,6 +3731,7 @@ __metadata:
|
||||||
"@opensumi/ide-overlay": "workspace:*"
|
"@opensumi/ide-overlay": "workspace:*"
|
||||||
"@opensumi/ide-terminal-next": "workspace:*"
|
"@opensumi/ide-terminal-next": "workspace:*"
|
||||||
"@opensumi/ide-theme": "workspace:*"
|
"@opensumi/ide-theme": "workspace:*"
|
||||||
|
"@opensumi/ide-utils": "workspace:*"
|
||||||
"@opensumi/ide-workspace": "workspace:*"
|
"@opensumi/ide-workspace": "workspace:*"
|
||||||
"@opensumi/ide-workspace-edit": "workspace:*"
|
"@opensumi/ide-workspace-edit": "workspace:*"
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
|
|
Loading…
Reference in New Issue