-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
- Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.95.0, commit 912bb68
- OS Version: Windows 10, Version 22H2. Running VSCode inside WSL2 Ubuntu 22.04.5 LTS
Description
Invoking revealFileInOS
programatically via a VSCode Extension doesn't do anything (does not even error). Manually invoking this command via the command palette works.
I'd love to invoke this command programatically to provide a command allowing users of our extension to open the extension's log file in their explorer/finder/whatever and then just drag-and-drop this file into a new GitHub issue (instead of pasting the contents in the issue, making it hard to read).
Steps to reproduce
Inside the activate
function of a VSCode Extension:
vscode.commands.registerCommand('manim-notebook.openLogFileTest', async () => {
const myFilePath= vscode.Uri.joinPath(<some-paths-joined-together>);
await vscode.commands.executeCommand('revealFileInOS', myFilePath); // also tested with myFilePath.fsPath
});
This is inspired by what the built-in TypeScript Language Server does here:
vscode/extensions/typescript-language-features/src/typescriptServiceClient.ts
Lines 580 to 586 in 9ae3d69
try { | |
await vscode.commands.executeCommand('revealFileInOS', this.serverState.server.tsServerLog.uri); | |
return true; | |
} catch { | |
vscode.window.showWarningMessage(vscode.l10n.t("Could not open TS Server log file")); | |
return false; | |
} |
I can verify that myFilePath
has a reference to a valid file as expected by executing this beforehand:
const doc = await vscode.workspace.openTextDocument(myFilePath);
await window.showTextDocument(doc);
This correctly opens myFilePath
in the editor and shows its contents.
Related issues
- Command
revealFileInOS
breaks with Explorer view NOT opened #110869.
I verified that the explorer view is opened in this case. I even added the following beforehand but it still doesn't work.
await vscode.commands.executeCommand('workbench.view.explorer');
- "Reveal in Explorer" hotkey doesn't work #124825.
The last comment there says: "Ok, so the gist of the issue seems to be "Reveal in Explorer does not work for WSL". Let me reopen..." Interestingly, the issue shows as "closed", even though it was re-opened. - Hotkey "ctrl+alt+f" of "reveal file in explorer" can't open windows explorer, but file-tab right menu can open it. #92893.
I'm aware that the hotkey by design adds an additional!editorFocus
where-clause. I've even removed that one and the hotkey works fine for me. As expected, it opens the respective file (residing in Linux) in my Windows explorer. It's just that it doesn't work when programatically invoked via the extension.