Skip to content

Commit 54b4938

Browse files
committed
feat: Improve file path handling in contextFileSelected
- Add fallback for relative path calculation - Handle cases where workspaceDir is undefined - Ensure fileSelected is always used as a fallback
1 parent c25ef50 commit 54b4938

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/context/contextFileSelected.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export async function handleFileSelected(fileSelected: string) {
1919

2020
// get relative path of workspace
2121
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
22-
const relativePath = path.relative(workspaceDir!, fileSelected);
22+
const relativePath = workspaceDir
23+
? path.relative(workspaceDir, fileSelected)
24+
: fileSelected;
2325

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

0 commit comments

Comments
 (0)