MCPcopy
hub / github.com/conwnet/github1s / openFileToEditor

Function openFileToEditor

extensions/github1s/src/commands/editor.ts:39–55  ·  view source on GitHub ↗
(fileUri)

Source from the content-addressed store, hash-verified

37};
38
39const openFileToEditor = async (fileUri) => {
40 const isCurrentAuthority = fileUri.authority === (await router.getAuthority());
41
42 // In order to make the file explorer focus corresponding file when
43 // the `fileUri.authority` equals `current authority`, set the
44 // `fileUri.authority` to '' in this case
45 const targetFileUri = isCurrentAuthority ? fileUri.with({ authority: '' }) : fileUri;
46
47 let editorLabel: string | undefined = undefined;
48 if (!isCurrentAuthority) {
49 // the authority here should be `{repo}+{commitSha}`
50 const [_repo, commitSha] = targetFileUri.authority.split('+');
51 editorLabel = `${basename(targetFileUri.path)} (${commitSha.slice(0, 7)})`;
52 }
53
54 return vscode.commands.executeCommand('vscode.open', targetFileUri, { preview: false }, editorLabel);
55};
56
57// open the left file in the diff editor title
58const commandDiffViewOpenLeftFile = async (fileUri: vscode.Uri) => {

Callers 2

Calls 2

basenameFunction · 0.90
getAuthorityMethod · 0.80

Tested by

no test coverage detected