-
Notifications
You must be signed in to change notification settings - Fork 35.9k
Fix markdown setting scope links #274935
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
base: main
Are you sure you want to change the base?
Fix markdown setting scope links #274935
Conversation
Fixes microsoft#272118 Lets markdown strings use internal uris for links that should be handled entirely by the action handler instead of the opener. Uses this to support setting scope links
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors link creation in markdown to use centralized helper functions instead of inline string concatenation. The changes introduce createMarkdownLink for general links and rename markdownCommandLink to createMarkdownCommandLink for consistency, adds support for internal URI scheme links, and updates all call sites across the codebase.
- Refactored markdown link creation to use new helper functions
createMarkdownLinkandcreateMarkdownCommandLink - Added support for
Schemas.internalin the markdown renderer and opener service - Introduced
SettingScopeLinknamespace for creating and parsing internal setting scope links
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/base/common/htmlContent.ts | Added createMarkdownLink function and renamed markdownCommandLink to createMarkdownCommandLink |
| src/vs/base/browser/markdownRenderer.ts | Added Schemas.internal to allowed schemes in sanitizer config |
| src/vs/editor/browser/services/openerService.ts | Added early return for internal scheme URIs to prevent them from being opened |
| src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts | Replaced inline markdown link construction with createMarkdownLink, added SettingScopeLink namespace |
| src/vs/workbench/contrib/mcp/browser/mcpServersView.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/mcp/browser/mcpCommands.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationPart.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/chat/browser/chatContentParts/chatMcpServersInteractionContentPart.ts | Updated to use createMarkdownCommandLink |
| src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.ts | Updated to use createMarkdownCommandLink |
| let defaultOverrideHoverContent; | ||
| if (!Array.isArray(sourceToDisplay)) { | ||
| defaultOverrideHoverContent = localize('defaultOverriddenDetails', "Default setting value overridden by `{0}`", sourceToDisplay); | ||
| defaultOverrideHoverContent = localize('defaultOverriddenDetails', "Default setting value overridden by `{ 0 } `", sourceToDisplay); |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The localization string contains incorrect spacing. Should be {0} instead of { 0 } .
| defaultOverrideHoverContent = localize('defaultOverriddenDetails', "Default setting value overridden by `{ 0 } `", sourceToDisplay); | |
| defaultOverrideHoverContent = localize('defaultOverriddenDetails', "Default setting value overridden by `{0}`", sourceToDisplay); |
| export function parse(link: string): string { | ||
| const uri = URI.parse(link); | ||
| return decodeURIComponent(uri.query); |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parse function is used with optional chaining on line 483 (SettingScopeLink.parse(url)?.split(':')), but it always returns a string. It should return string | undefined to handle cases where the URI might be invalid or the query might be empty. Consider adding validation or changing the return type to match the usage pattern.
| export function parse(link: string): string { | |
| const uri = URI.parse(link); | |
| return decodeURIComponent(uri.query); | |
| export function parse(link: string): string | undefined { | |
| const uri = URI.parse(link); | |
| if (uri.query) { | |
| return decodeURIComponent(uri.query); | |
| } | |
| return undefined; |
Fixes #272118
Lets markdown strings use internal uris for links that should be handled entirely by the action handler instead of the opener. Uses this to support setting scope links