Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/test-provider/test-item-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { JestExtOutput } from '../JestExt/output-terminal';
import { tiContextManager } from './test-item-context-manager';
import { toAbsoluteRootPath } from '../helpers';
import { runModeDescription } from '../JestExt/run-mode';
import { isVirtualWorkspaceFolder } from '../virtual-workspace-folder';

interface JestRunnable {
getJestRunRequest: () => JestExtRequestType;
Expand Down Expand Up @@ -129,10 +130,13 @@ export class WorkspaceRoot extends TestItemDataBase {
this.registerEvents();
}
createTestItem(): vscode.TestItem {
const workspaceFolder = this.context.ext.workspace;
const item = this.context.createTestItem(
`${extensionId}:${this.context.ext.workspace.name}`,
this.context.ext.workspace.name,
this.context.ext.workspace.uri,
`${extensionId}:${workspaceFolder.name}`,
workspaceFolder.name,
isVirtualWorkspaceFolder(workspaceFolder)
? workspaceFolder.effectiveUri
: workspaceFolder.uri,
this,
undefined,
['run']
Expand Down
11 changes: 6 additions & 5 deletions src/virtual-workspace-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ export class VirtualFolderBasedCache<T extends FolderAwareItem> {
}

/**
* a virtual workspace folder is a folder resides in a physical workspace folder but might have
* A virtual workspace folder is a folder resides in a physical workspace folder but might have
* different name and separate jest settings. A physical workspace folder can have multiple virtual folders.

* Note: The class will have the same index as the actual workspace folder, but different name and uri (if it has set a different rootPath).
* Note: The class will have the same index and the uri as the actual workspace folder, but a different name.
*/
export class VirtualWorkspaceFolder implements vscode.WorkspaceFolder {
// the URI with the rootPath applied
private effectiveUri: vscode.Uri;
/** URI pointing to the virtual folder, including rootPath */
public readonly effectiveUri: vscode.Uri;

constructor(
public readonly actualWorkspaceFolder: vscode.WorkspaceFolder,
public readonly name: string,
Expand All @@ -110,7 +111,7 @@ export class VirtualWorkspaceFolder implements vscode.WorkspaceFolder {
return this.actualWorkspaceFolder.uri;
}

/** check if the given uri falls within the virtual folder's path */
/** Check if the given uri falls within the virtual folder's path */
isInWorkspaceFolder(uri: vscode.Uri): boolean {
return uri.fsPath.startsWith(this.effectiveUri.fsPath);
}
Expand Down