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
This commit is contained in:
parent
c25ef505b0
commit
54b49389c5
@ -19,7 +19,9 @@ export async function handleFileSelected(fileSelected: string) {
|
|||||||
|
|
||||||
// get relative path of workspace
|
// get relative path of workspace
|
||||||
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
|
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
|
||||||
const relativePath = path.relative(workspaceDir!, fileSelected);
|
const relativePath = workspaceDir
|
||||||
|
? path.relative(workspaceDir, fileSelected)
|
||||||
|
: fileSelected;
|
||||||
|
|
||||||
// convert fileContent to markdown code block with languageId and file path
|
// convert fileContent to markdown code block with languageId and file path
|
||||||
const data = {
|
const data = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user