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结尾
|
||||
'!packages/**/*-contribution.ts',
|
||||
'!packages/startup/**/*.ts',
|
||||
// Test 功能暂未完成
|
||||
// Test, Notebook 模块暂不覆盖
|
||||
'!packages/testing/**/*.ts',
|
||||
'!packages/notebook/**/*.ts',
|
||||
// CLI 不需要测试
|
||||
'!packages/remote-cli/**/*.ts',
|
||||
'!packages/core-electron-main/**/*.ts',
|
||||
|
|
|
@ -236,9 +236,11 @@ export class TreeNode implements ITreeNode {
|
|||
get path(): string {
|
||||
if (!this._path) {
|
||||
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 {
|
||||
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;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
"@opensumi/ide-overlay": "workspace:*",
|
||||
"@opensumi/ide-terminal-next": "workspace:*",
|
||||
"@opensumi/ide-theme": "workspace:*",
|
||||
"@opensumi/ide-utils": "workspace:*",
|
||||
"@opensumi/ide-workspace": "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 { ViewContentGroups } from '@opensumi/ide-main-layout/lib/browser/views-registry';
|
||||
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 { IFileTreeService, PasteTypes, RESOURCE_VIEW_ID } from '../common';
|
||||
|
@ -778,9 +779,15 @@ export class FileTreeContribution
|
|||
}
|
||||
if (uri.scheme === DIFF_SCHEME) {
|
||||
const query = uri.getParsedQuery();
|
||||
// 需要file scheme才能与工作区计算相对路径
|
||||
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;
|
||||
if (this.fileTreeService.isMultipleWorkspace) {
|
||||
// 多工作区额外处理
|
||||
|
|
|
@ -70,7 +70,7 @@ export class EditorFile extends TreeNode {
|
|||
public dirty: boolean = false,
|
||||
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() {
|
||||
|
|
|
@ -127,16 +127,16 @@ export class OpenedEditorService extends Tree {
|
|||
.join(groupName)
|
||||
.join(
|
||||
resource && (resource as IResource).uri
|
||||
? (resource as IResource).uri.toString()
|
||||
: (resource as URI).toString(),
|
||||
? (resource as IResource).uri.codeUri.fsPath
|
||||
: (resource as URI).codeUri.fsPath,
|
||||
)
|
||||
.toString();
|
||||
} else {
|
||||
path = new Path(path)
|
||||
.join(
|
||||
resource && (resource as IResource).uri
|
||||
? (resource as IResource).uri.toString()
|
||||
: (resource as URI).toString(),
|
||||
? (resource as IResource).uri.codeUri.fsPath
|
||||
: (resource as URI).codeUri.fsPath,
|
||||
)
|
||||
.toString();
|
||||
}
|
||||
|
|
|
@ -3731,6 +3731,7 @@ __metadata:
|
|||
"@opensumi/ide-overlay": "workspace:*"
|
||||
"@opensumi/ide-terminal-next": "workspace:*"
|
||||
"@opensumi/ide-theme": "workspace:*"
|
||||
"@opensumi/ide-utils": "workspace:*"
|
||||
"@opensumi/ide-workspace": "workspace:*"
|
||||
"@opensumi/ide-workspace-edit": "workspace:*"
|
||||
languageName: unknown
|
||||
|
|
Loading…
Reference in New Issue