Skip to content

Commit

Permalink
fix: fix filepath when git url provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
icycodes committed May 28, 2024
1 parent f2ab4db commit cdb405a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions clients/vscode/src/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,20 @@ export class Commands {

const editor = window.activeTextEditor;
if (editor) {
const uri = editor.document.uri;
const text = editor.document.getText(editor.selection);
const repo = this.gitProvider.getRepository(editor.document.uri);
const workspaceFolder = workspace.getWorkspaceFolder(uri);
const repo = this.gitProvider.getRepository(uri);
const remoteUrl = repo ? this.gitProvider.getDefaultRemoteUrl(repo) : undefined;
const workspaceFolder = workspace.workspaceFolders?.[0]?.uri.fsPath || "";
let filePath = uri.toString();
if (repo) {
filePath = filePath.replace(repo.rootUri.toString(), "");
} else if (workspaceFolder) {
filePath = filePath.replace(workspaceFolder.uri.toString(), "");
}

commands.executeCommand("tabby.chatView.focus");

const filePath = editor.document.fileName.replace(workspaceFolder, "");
this.chatViewProvider.sendMessage({
message: "Explain the selected code:",
selectContext: {
Expand Down

0 comments on commit cdb405a

Please sign in to comment.