update getFullyQualifiedPath to use ide
This commit is contained in:
parent
c43680bdb5
commit
17081dfa77
4 changed files with 18 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { SlashCommand } from "../..";
|
||||
import { getFullyQualifiedPath } from "../../../extensions/vscode/src/util/util";
|
||||
import { VsCodeIde } from "../../../extensions/vscode/src/VsCodeIde";
|
||||
import { stripImages } from "../../llm/images";
|
||||
|
||||
const MultiFileEditSlashCommand: SlashCommand = {
|
||||
|
|
@ -11,7 +12,7 @@ const MultiFileEditSlashCommand: SlashCommand = {
|
|||
selectedCode.map(async (item) => {
|
||||
// Split the range string from the filename, e.g. `filename.ts (1-2) -> [filename.ts, (1-2)]`
|
||||
const [filepath, rangeStr] = item.filepath.split(" ");
|
||||
const fullPath = getFullyQualifiedPath(filepath);
|
||||
const fullPath = getFullyQualifiedPath(ide as VsCodeIde, filepath);
|
||||
|
||||
if (!fullPath) {
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import { Battery } from "./util/battery";
|
|||
import { getFullyQualifiedPath } from "./util/util";
|
||||
import { uriFromFilePath } from "./util/vscode";
|
||||
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
import { VsCodeIde } from "./VsCodeIde";
|
||||
|
||||
let fullScreenPanel: vscode.WebviewPanel | undefined;
|
||||
|
||||
|
|
@ -188,7 +189,7 @@ function focusGUI() {
|
|||
|
||||
// Copy everything over from extension.ts
|
||||
const commandsMap: (
|
||||
ide: IDE,
|
||||
ide: VsCodeIde,
|
||||
extensionContext: vscode.ExtensionContext,
|
||||
sidebar: ContinueGUIWebviewViewProvider,
|
||||
configHandler: ConfigHandler,
|
||||
|
|
@ -261,8 +262,10 @@ const commandsMap: (
|
|||
|
||||
if (fullPath instanceof vscode.Uri) {
|
||||
fullPath = fullPath.fsPath;
|
||||
} else if (fullPath) {
|
||||
fullPath = getFullyQualifiedPath(ide, fullPath);
|
||||
} else {
|
||||
fullPath = getFullyQualifiedPath(fullPath);
|
||||
console.warn(`Unable to resolve filepath: ${newFilepath}`);
|
||||
}
|
||||
|
||||
verticalDiffManager.clearForFilepath(fullPath, true);
|
||||
|
|
@ -278,8 +281,11 @@ const commandsMap: (
|
|||
|
||||
if (fullPath instanceof vscode.Uri) {
|
||||
fullPath = fullPath.fsPath;
|
||||
} else if (fullPath) {
|
||||
fullPath = getFullyQualifiedPath(ide, fullPath);
|
||||
} else {
|
||||
fullPath = getFullyQualifiedPath(fullPath);
|
||||
console.warn(`Unable to resolve filepath: ${newFilepath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
verticalDiffManager.clearForFilepath(fullPath, false);
|
||||
|
|
@ -807,7 +813,7 @@ const commandsMap: (
|
|||
|
||||
export function registerAllCommands(
|
||||
context: vscode.ExtensionContext,
|
||||
ide: IDE,
|
||||
ide: VsCodeIde,
|
||||
extensionContext: vscode.ExtensionContext,
|
||||
sidebar: ContinueGUIWebviewViewProvider,
|
||||
configHandler: ConfigHandler,
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ export class VsCodeMessenger {
|
|||
) {
|
||||
/** WEBVIEW ONLY LISTENERS **/
|
||||
this.onWebview("showFile", (msg) => {
|
||||
const fullPath = getFullyQualifiedPath(msg.data.filepath);
|
||||
const fullPath = getFullyQualifiedPath(this.ide, msg.data.filepath);
|
||||
|
||||
if (fullPath) {
|
||||
this.ide.openFile(fullPath);
|
||||
|
|
@ -159,7 +159,7 @@ export class VsCodeMessenger {
|
|||
});
|
||||
|
||||
this.onWebview("applyToFile", async ({ data }) => {
|
||||
const fullPath = getFullyQualifiedPath(data.filepath);
|
||||
const fullPath = getFullyQualifiedPath(ide, data.filepath);
|
||||
|
||||
if (!fullPath) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const os = require("node:os");
|
||||
import path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
|
||||
function charIsEscapedAtIndex(index: number, str: string): boolean {
|
||||
if (index === 0) {
|
||||
|
|
@ -123,17 +124,12 @@ export function getExtensionVersion(): string {
|
|||
return extension?.packageJSON.version || "0.1.0";
|
||||
}
|
||||
|
||||
export function getFullyQualifiedPath(filepath?: string) {
|
||||
if (!filepath) return;
|
||||
if (path.isAbsolute(filepath)) return filepath;
|
||||
export function getFullyQualifiedPath(ide: VsCodeIde, filepath: string) {
|
||||
if (ide.ideUtils.path.isAbsolute(filepath)) return filepath;
|
||||
|
||||
const workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
|
||||
if (workspaceFolders && workspaceFolders.length > 0) {
|
||||
return path.join(workspaceFolders[0].uri.fsPath, filepath);
|
||||
} else {
|
||||
vscode.window.showErrorMessage(
|
||||
"Unable to resolve filepath: no workspace folder found",
|
||||
);
|
||||
return ide.ideUtils.path.join(workspaceFolders[0].uri.fsPath, filepath);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue