Skip to content

Commit

Permalink
Use URI object when invoking vscode.open (#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Jul 17, 2024
1 parent 124be35 commit 085e677
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions vscode/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from "path";

import * as vscode from "vscode";

import { Workspace } from "./workspace";
Expand Down Expand Up @@ -51,17 +53,24 @@ export async function openUris(uris: string[]) {
}

const items: ({ uri: vscode.Uri } & vscode.QuickPickItem)[] = uris.map(
(uri) => ({
label: uri,
uri: vscode.Uri.parse(uri),
}),
(uriString) => {
const uri = vscode.Uri.parse(uriString);

return {
label: path.basename(uri.fsPath),
iconPath: new vscode.ThemeIcon("go-to-file"),
uri,
};
},
);

const pickedFile = await vscode.window.showQuickPick(items);
const pickedFile = await vscode.window.showQuickPick(items, {
title: "Select a file to jump to",
});

if (!pickedFile) {
return;
}

await vscode.commands.executeCommand("vscode.open", pickedFile.label);
await vscode.commands.executeCommand("vscode.open", pickedFile.uri);
}

0 comments on commit 085e677

Please sign in to comment.