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

Use webRoot config for source path resolution #885

Merged
merged 4 commits into from
Feb 18, 2022
Merged

Conversation

bwalderman
Copy link
Contributor

@bwalderman bwalderman commented Feb 15, 2022

Fixes #787

The webRoot config was not being considered when mapping a URL to a path on the filesystem. This prevented file links in the devtools from successfully opening files in the editor. The fix is to treat webRoot as an entry in pathMapping.

This fixes the webRoot property in Microsoft Edge DevTools' own extension settings, but the extension isn't currently aware of webRoot and pathMapping properties found in launch.json configs. A separate PR microsoft/vscode-js-debug#1206 plumbs those through to our extension so they will work as expected.

@bwalderman bwalderman requested a review from vidorteg February 15, 2022 20:51
@bwalderman bwalderman requested review from hkal and antross and removed request for vidorteg February 16, 2022 17:18
src/utils.ts Outdated
@@ -471,6 +471,11 @@ export function getRuntimeConfig(config: Partial<IUserConfig> = {}): IRuntimeCon
}
}

// The webRoot config is equivalent to a pathMapping entry of { '/': '${webRoot}' }.
if (!pathMapping.hasOwnProperty('/')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't working for me because I'm getting a pathMapping object back from the settings.get('pathMapping') call that already has {'/': '${workspaceFolder}'}. However, I don't have that set in my settings.json file so I'm still trying to figure out where it's coming from.

@mliao95 any idea what might be causing this?

Copy link

Choose a reason for hiding this comment

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

Not off the top of my head. I'll dig into it

Copy link
Contributor

Choose a reason for hiding this comment

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

@bwalderman I think even once we figure out what's going on with settings.get this may not work as expected since the fallback SETTINGS_DEFAULT_PATH_MAPPING also specifies a root entry.

Copy link

Choose a reason for hiding this comment

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

Sorry - got sidetracked, not sure if you already figured it out, but the default value for pathMapping is {'/': '${workspaceFolder}'} as defined in the package.json:
https://github.com/microsoft/vscode-edge-devtools/blob/main/package.json#L217

Copy link
Contributor

Choose a reason for hiding this comment

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

I had not figured that out - thanks!

@mliao95 any thoughts on what a correct fix would be here given we're often already going to have a default / specified?

  1. Should we give precedence to webRoot depending on where it originates from?
  2. Or give precedence if it's anything other than our default?
  3. Or should we abandon this change and advise users to set a pathMapping for / themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case I think we should always give precedence to webRoot. The default webRoot is {$workspaceFolder}, so this will not affect the default pathMapping unless the user has specified something else for webRoot.

Copy link

@mliao95 mliao95 Feb 17, 2022

Choose a reason for hiding this comment

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

IMO I think the priority based off of my interpretation of user expectations should be:
User defined extension settings > webRoot > default setting value.

Let me know if you agree and we can run with that. Otherwise, open to hear your thoughts.

Edit:
On second thought, I'm okay webRoot taking precedence over the extension settings. The difference is pretty minor and removes some complexity in the priority logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @mliao95. Based on the issue report, I think user expectations are that existing launch configs with webRoot properties just work with our extension the way they do for vscode JS debugging sessions. On top of that, the launch config should take priority over the extension setting because any logic on the vscode-js-debug side won't even be aware of our extension settings.

@mliao95 mliao95 self-requested a review February 18, 2022 18:49
@bwalderman bwalderman merged commit 9f1edda into main Feb 18, 2022
@vidorteg vidorteg deleted the user/brwalder/webRoot branch January 30, 2024 03:37
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.

Error while opening CSS file in editor
3 participants