-
Notifications
You must be signed in to change notification settings - Fork 34.8k
Description
Version: 1.55.0-insider (user setup)
Commit: 111a6ce
Date: 2021-03-18T05:14:49.087Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042
Possibly related to #110982
I have been working on finding a way to leave a Live Share session upon a user reload. Our current strategy, based on the discussion in #110982 was to delete the Live Share workspace files during deactivate. I have built out this approach but after the workspace has been deleted, VS Code has a workspace open with the title Visual Studio Live Share (Workspace). I made the following test extension to demonstrate the behavior we are seeing. Can you explain why this behavior is happening? Is there a way to close the current workspace during the reloading process to achieve our desired behavior?
Steps to Reproduce:
- Run the attached extension
- Open the folder C:\Users\UserProfile\AppData\Local\Temp\vsliveshare
- From the extension development host, join a Live Share session
- Observe the workspace be added to the vsliveshare folder
- From the command palette, run the command Delete temp workspace files upon reload
- Reload the window
- Observe workspace folder being deleted via the logs and the vsliveshare folder
Expected Behavior: VS Code will go back to being in a fresh state with no workspaces open
Actual Behavior: VS Code has the deleted workspace open and is in a bad state
extension.ts
import * as vscode from 'vscode';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
export var shouldDeleteUponReload: boolean;
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "delete-workspace" is now active!');
let disposable = vscode.commands.registerCommand('delete-workspace.shouldDeleteUponReload', () => {
shouldDeleteUponReload = true;
});
context.subscriptions.push(disposable);
}
export async function deactivate() {
const LIVESHARE_WORKSPACE_TEMP_DIR = path.join(os.tmpdir(), 'vsliveshare');
console.log(shouldDeleteUponReload);
if (shouldDeleteUponReload) {
await fs.readdir(LIVESHARE_WORKSPACE_TEMP_DIR, (err, files) => {
files.forEach(file => {
let dir = LIVESHARE_WORKSPACE_TEMP_DIR + '\\' + file;
fs.rmdir(dir, { recursive: true }, (err) =>{ console.log(err?.message); });
console.log("Removed: " + dir);
});
});
}
}
cc @bpasero