Skip to content

Commit ed3dcfe

Browse files
committed
use absolute path
1 parent 8914e6f commit ed3dcfe

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/extension/replay/vscode-node/editHelper.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ export class EditHelper {
1111
constructor(private readonly workspaceService: IWorkspaceService) { }
1212

1313
public async makeEdit(edits: FileEdits, stream: ChatResponseStream) {
14-
const uri = Uri.file(edits.path);
14+
let uri: Uri;
15+
if (!edits.path.startsWith('/') && !edits.path.match(/^[a-zA-Z]:/)) {
16+
// Relative path - join with first workspace folder
17+
const workspaceFolders = this.workspaceService.getWorkspaceFolders();
18+
if (workspaceFolders.length > 0) {
19+
uri = Uri.joinPath(workspaceFolders[0], edits.path);
20+
} else {
21+
throw new Error('No workspace folder available to resolve relative path: ' + edits.path);
22+
}
23+
} else {
24+
// Absolute path
25+
uri = Uri.file(edits.path);
26+
}
27+
1528
await this.ensureFileExists(uri);
1629

1730
stream.markdown('\n```\n');

0 commit comments

Comments
 (0)