Skip to content

revealFileInOS invoked programatically does not do anything #232522

@Splines

Description

@Splines
  • 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:

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

await vscode.commands.executeCommand('workbench.view.explorer');

Metadata

Metadata

Assignees

Labels

*dev-questionVS Code Extension Development Question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions