Skip to content

Commit 0de9bec

Browse files
alexr00Copilot
andauthored
Settings links in Release Notes do nothing (microsoft#268455)
* Settings links in Release Notes do nothing Part of microsoft#268443 * Update src/vs/workbench/contrib/update/test/browser/releaseNotesRenderer.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix test --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent abb3be8 commit 0de9bec

4 files changed

Lines changed: 60 additions & 4 deletions

File tree

src/vs/workbench/contrib/update/browser/releaseNotesEditor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,10 @@ export async function renderReleaseNotesMarkdown(
626626
sanitizerConfig: {
627627
allowRelativeMediaPaths: true,
628628
allowedLinkProtocols: {
629-
override: [Schemas.http, Schemas.https, Schemas.command]
630-
}
629+
override: [Schemas.http, Schemas.https, Schemas.command, Schemas.codeSetting]
630+
},
631+
allowedTags: { augment: ['nav', 'svg', 'path'] },
632+
allowedAttributes: { augment: ['aria-role', 'viewBox', 'fill', 'xmlns', 'd'] }
631633
},
632634
markedExtensions: [{
633635
renderer: {

src/vs/workbench/contrib/update/test/browser/__snapshots__/Release_notes_renderer_Should_render_TOC.0.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
<p>text</p>
1111
</blockquote>
1212
<div class="toc-nav-layout">
13-
13+
<nav id="toc-nav">
1414
<div>In this update</div>
1515
<ul>
1616
<li><a href="#chat">test</a></li>
1717
</ul>
18-
18+
</nav>
1919
<div class="notes-main">
2020

2121
<h2 id="test">Test</h2>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Here is a setting: <code tabindex="0"><a aria-role="button" title="View or change setting" class="codesetting" href="code-setting://editor.wordWrap/on"><svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" height="14" width="14"><path d="M9.1 4.4L8.6 2H7.4l-.5 2.4-.7.3-2-1.3-.9.8 1.3 2-.2.7-2.4.5v1.2l2.4.5.3.8-1.3 2 .8.8 2-1.3.8.3.4 2.3h1.2l.5-2.4.8-.3 2 1.3.8-.8-1.3-2 .3-.8 2.3-.4V7.4l-2.4-.5-.3-.8 1.3-2-.8-.8-2 1.3-.7-.2zM9.4 1l.5 2.4L12 2.1l2 2-1.4 2.1 2.4.4v2.8l-2.4.5L14 12l-2 2-2.1-1.4-.5 2.4H6.6l-.5-2.4L4 13.9l-2-2 1.4-2.1L1 9.4V6.6l2.4-.5L2.1 4l2-2 2.1 1.4.4-2.4h2.8zm.6 7c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zM8 9c.6 0 1-.4 1-1s-.4-1-1-1-1 .4-1 1 .4 1 1 1z"></path></svg>
2+
<span class="separator"></span>
3+
<span class="setting-name">editor.wordWrap</span>
4+
</a></code> and another <code tabindex="0"><a aria-role="button" title="View or change setting" class="codesetting" href="code-setting://editor.wordWrap/off"><svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" height="14" width="14"><path d="M9.1 4.4L8.6 2H7.4l-.5 2.4-.7.3-2-1.3-.9.8 1.3 2-.2.7-2.4.5v1.2l2.4.5.3.8-1.3 2 .8.8 2-1.3.8.3.4 2.3h1.2l.5-2.4.8-.3 2 1.3.8-.8-1.3-2 .3-.8 2.3-.4V7.4l-2.4-.5-.3-.8 1.3-2-.8-.8-2 1.3-.7-.2zM9.4 1l.5 2.4L12 2.1l2 2-1.4 2.1 2.4.4v2.8l-2.4.5L14 12l-2 2-2.1-1.4-.5 2.4H6.6l-.5-2.4L4 13.9l-2-2 1.4-2.1L1 9.4V6.6l2.4-.5L2.1 4l2-2 2.1 1.4.4-2.4h2.8zm.6 7c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zM8 9c.6 0 1-.4 1-1s-.4-1-1-1-1 .4-1 1 .4 1 1 1z"></path></svg>
5+
<span class="separator"></span>
6+
<span class="setting-name">editor.wordWrap</span>
7+
</a></code></p>

src/vs/workbench/contrib/update/test/browser/releaseNotesRenderer.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { IContextMenuService } from '../../../../../platform/contextview/browser
1010
import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js';
1111
import { IExtensionService } from '../../../../services/extensions/common/extensions.js';
1212
import { SimpleSettingRenderer } from '../../../markdown/browser/markdownSettingRenderer.js';
13+
import { IPreferencesService } from '../../../../services/preferences/common/preferences.js';
1314
import { renderReleaseNotesMarkdown } from '../../browser/releaseNotesEditor.js';
15+
import { URI } from '../../../../../base/common/uri.js';
16+
import { Emitter } from '../../../../../base/common/event.js';
1417

1518

1619
suite('Release notes renderer', () => {
@@ -55,4 +58,48 @@ Navigation End -->
5558
const result = await renderReleaseNotesMarkdown(content, extensionService, languageService, instantiationService.createInstance(SimpleSettingRenderer));
5659
await assertSnapshot(result.toString());
5760
});
61+
62+
test('Should render code settings', async () => {
63+
// Stub preferences service with a known setting so the SimpleSettingRenderer treats it as valid
64+
const testSettingId = 'editor.wordWrap';
65+
instantiationService.stub(IPreferencesService, <Partial<IPreferencesService>>{
66+
_serviceBrand: undefined,
67+
onDidDefaultSettingsContentChanged: new Emitter<URI>().event,
68+
userSettingsResource: undefined as any,
69+
workspaceSettingsResource: null,
70+
getFolderSettingsResource: () => null,
71+
createPreferencesEditorModel: async () => null,
72+
getDefaultSettingsContent: () => undefined,
73+
hasDefaultSettingsContent: () => false,
74+
createSettings2EditorModel: () => { throw new Error('not needed'); },
75+
openPreferences: async () => undefined,
76+
openRawDefaultSettings: async () => undefined,
77+
openSettings: async () => undefined,
78+
openApplicationSettings: async () => undefined,
79+
openUserSettings: async () => undefined,
80+
openRemoteSettings: async () => undefined,
81+
openWorkspaceSettings: async () => undefined,
82+
openFolderSettings: async () => undefined,
83+
openGlobalKeybindingSettings: async () => undefined,
84+
openDefaultKeybindingsFile: async () => undefined,
85+
openLanguageSpecificSettings: async () => undefined,
86+
getEditableSettingsURI: async () => null,
87+
getSetting: (id: string) => {
88+
if (id === testSettingId) {
89+
// Provide the minimal fields accessed by SimpleSettingRenderer
90+
return <any>{
91+
key: testSettingId,
92+
value: 'off',
93+
type: 'string'
94+
};
95+
}
96+
return undefined;
97+
},
98+
createSplitJsonEditorInput: () => { throw new Error('not needed'); }
99+
});
100+
101+
const content = `Here is a setting: \`setting(${testSettingId}:on)\` and another \`setting(${testSettingId}:off)\``;
102+
const result = await renderReleaseNotesMarkdown(content, extensionService, languageService, instantiationService.createInstance(SimpleSettingRenderer));
103+
await assertSnapshot(result.toString());
104+
});
58105
});

0 commit comments

Comments
 (0)