Skip to content

Commit c25ef50

Browse files
committed
feat: Improve file path handling in contextCodeSelected
- Add fallback for relative path calculation - Handle cases where workspaceDir is undefined - Ensure fileSelected is used when no workspace folder exists
1 parent 32f078b commit c25ef50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/context/contextCodeSelected.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export async function handleCodeSelected(fileSelected: string, codeSelected: str
1616

1717
// get relative path of workspace
1818
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
19-
const relativePath = path.relative(workspaceDir!, fileSelected);
19+
const relativePath = workspaceDir
20+
? path.relative(workspaceDir, fileSelected)
21+
: fileSelected;
2022

2123
// convert fileContent to markdown code block with languageId and file path
2224
const data = {

0 commit comments

Comments
 (0)