-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
revealFileInOS
invoked programatically does not do anything
#232522
Comments
revealFileInOS
invoked programatically does not do anything
Note this was already a problem in the prior release |
We have a great extension developer community over on GitHub discussions and Slack where extension authors help each other. This is a great place for you to ask questions and find support. Happy Coding! |
Thanks for pointing me to the discussions, I didn't know these existed. If anyone from the Internet stumbles upon this issue in some years, here's what I now came up with to resolve this issue. The problem was that the /**
* Opens a file in the OS file explorer.
*
* @param uri The URI of the file to reveal.
*/
async function revealFileInOS(uri: vscode.Uri) {
if (vscode.env.remoteName === 'wsl') {
await vscode.commands.executeCommand('remote-wsl.revealInExplorer', uri);
} else {
await vscode.commands.executeCommand('revealFileInOS', uri);
}
} Then call it like this: try {
await revealFileInOS(logFilePath);
} catch (error: any) {
window.showErrorMessage(`Could not open log file in the`
+ ` OS file explorer: ${error?.message}`);
} |
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: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
I can verify that
myFilePath
has a reference to a valid file as expected by executing this beforehand:This correctly opens
myFilePath
in the editor and shows its contents.Related issues
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.
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.
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.The text was updated successfully, but these errors were encountered: