Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when opening file outside of any workspace #3815

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Flamefire
Copy link

Description

path.relative doesn't allow undefined as its parameter(s)
However this happens when getWorkspaceDirs returns an empty array which causes an error:

TypeError: The "from" argument must be of type string. Received undefined

So extract the first element and check if it is valid/set before further processing.

Testing instructions

Open a single file in VSCode and observe that the error message is no longer shown

`path.relative` doesn't allow `undefined` as its parameter(s)
However this happens when `getWorkspaceDirs` returns an empty array.
So extract the first element and check if it is valid/set before further processing.
Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit f3ace8b
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/6790e4031d796500085ae026
😎 Deploy Preview https://deploy-preview-3815--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sestinj sestinj requested a review from RomneyDa January 27, 2025 21:36
const [rootDirectory] = await this.ide.getWorkspaceDirs();
if (!rootDirectory)
return; // Not in a workspace
const relativeFilePath = path.relative(rootDirectory, filepath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flamefire super delayed review, sorry
ide.getWorkspaceDirs returns URIs, not paths, so the path.relative logic will fail. Can you update to use the findUriInDirs util in core/util/uri.ts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants