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
This commit is contained in:
parent
32f078bac2
commit
c25ef505b0
@ -16,7 +16,9 @@ export async function handleCodeSelected(fileSelected: string, codeSelected: str
|
|||||||
|
|
||||||
// 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