Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recent workspace tracking for devcontainer workspaces #14925

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class ContainerConnectionContribution extends AbstractRemoteRegistryContr
throw new Error(`Devcontainer file at ${filePath} not found in workspace`);
}

return this.doOpenInContainer(devcontainerFile, uri.toString());
return this.doOpenInContainer(devcontainerFile, uri.path.toString());
}

async getWorkspaceLabel(uri: URI): Promise<string | undefined> {
Expand All @@ -103,7 +103,7 @@ export class ContainerConnectionContribution extends AbstractRemoteRegistryContr
this.doOpenInContainer(devcontainerFile);
}

async doOpenInContainer(devcontainerFile: DevContainerFile, workspaceUri?: string): Promise<void> {
async doOpenInContainer(devcontainerFile: DevContainerFile, workspacePath?: string): Promise<void> {
const lastContainerInfoKey = `${LAST_USED_CONTAINER}:${devcontainerFile.path}`;
const lastContainerInfo = await this.workspaceStorageService.getData<LastContainerInfo | undefined>(lastContainerInfoKey);

Expand All @@ -113,7 +113,7 @@ export class ContainerConnectionContribution extends AbstractRemoteRegistryContr
nodeDownloadTemplate: this.remotePreferences['remote.nodeDownloadTemplate'],
lastContainerInfo,
devcontainerFile: devcontainerFile.path,
workspaceUri
workspacePath: workspacePath
});

this.workspaceStorageService.setData<LastContainerInfo>(lastContainerInfoKey, {
Expand All @@ -122,7 +122,7 @@ export class ContainerConnectionContribution extends AbstractRemoteRegistryContr
});

this.workspaceServer.setMostRecentlyUsedWorkspace(
`${DEV_CONTAINER_WORKSPACE_SCHEME}:${this.workspaceService.workspace?.resource.path}?${DEV_CONTAINER_PATH_QUERY}=${devcontainerFile.path}`);
`${DEV_CONTAINER_WORKSPACE_SCHEME}:${workspacePath ?? this.workspaceService.workspace?.resource.path}?${DEV_CONTAINER_PATH_QUERY}=${devcontainerFile.path}`);

this.openRemote(connectionResult.port, false, connectionResult.workspacePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ContainerConnectionOptions {
nodeDownloadTemplate?: string;
lastContainerInfo?: LastContainerInfo
devcontainerFile: string;
workspaceUri?: string;
workspacePath?: string;
}

export interface LastContainerInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class DockerContainerService {
async getOrCreateContainer(docker: Docker, options: ContainerConnectionOptions, outputProvider?: ContainerOutputProvider): Promise<Docker.Container> {
let container;

const workspace = new URI(options.workspaceUri ?? await this.workspaceServer.getMostRecentlyUsedWorkspace());
const workspace = new URI(options.workspacePath ?? await this.workspaceServer.getMostRecentlyUsedWorkspace());

if (options.lastContainerInfo && fs.statSync(options.devcontainerFile).mtimeMs < options.lastContainerInfo.lastUsed) {
try {
Expand Down
Loading