Change:
Testing Click on a setting link in the release notes Get a tooltip "View '<title' in Settings" context menu It seems strange to open a context menu on left-click and to open one with only a single menu item. Can we skip doing this if "View" is the only action?
My preference would be to keep it consistent so that a context menu always opens when the button is clicked. There was some discussion of adding a "copy setting id" item in there too, which would fix the only-one-item issue.
Will be fixed by , which adds a "copy" action to the menu.
Another option is to open the context menu when the "gear" icon is hit, but go directly to the setting if the text is clicked (or vise versa)

Discussion:
import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems'; import { IAction } from 'vs/base/common/actions'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; <ins> import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; </ins> <del> const codeSettingRegex = /^<code (codesetting)="([^s":]+)(?::([^s"]+))?">/; const codeFeatureRegex = /^<span (codefeature)="([^s":]+)(?::([^s"]+))?">/; </del> <ins> const codeSettingRegex = /^<code (codesetting)="([^s":]+)(?::([^"]+))?">/; const codeFeatureRegex = /^<span (codefeature)="([^s":]+)(?::([^"]+))?">/; </ins> export class SimpleSettingRenderer { private _defaultSettings: DefaultSettings;

@IConfigurationService private readonly _configurationService: IConfigurationService, @IContextMenuService private readonly _contextMenuService: IContextMenuService, @IPreferencesService private readonly _preferencesService: IPreferencesService, <del> @ITelemetryService private readonly _telemetryService: ITelemetryService </del> <ins> @ITelemetryService private readonly _telemetryService: ITelemetryService, @IClipboardService private readonly _clipboardService: IClipboardService </ins> ) { this._defaultSettings = new DefaultSettings([], ConfigurationTarget.USER); }

} }); <ins> actions.push({ class: undefined, enabled: true, id: 'copySettingId', tooltip: nls.localize('copySettingId', "Copy Setting ID"), label: nls.localize('copySettingId', "Copy Setting ID"), run: () => { this._clipboardService.writeText(settingId); } }); </ins> return actions; }

preferencesService = <IPreferencesService>{}; contextMenuService = <IContextMenuService>{}; Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration(configuration); <del> settingRenderer = new SimpleSettingRenderer(configurationService, contextMenuService, preferencesService, { publicLog2: () => { } } as any); </del> <ins> settingRenderer = new SimpleSettingRenderer(configurationService, contextMenuService, preferencesService, { publicLog2: () => { } } as any, { writeText: async () => { } } as any); </ins> }); suiteTeardown(() => {

test('actions with no value', () => { const uri = URI.parse(settingRenderer.settingToUriString('example.booleanSetting')); const actions = settingRenderer.getActions(uri); <del> assert.strictEqual(actions?.length, 1); </del> <ins> assert.strictEqual(actions?.length, 2); </ins> assert.strictEqual(actions[0].label, 'View "Example: Boolean Setting" in Settings'); });

const uri = URI.parse(settingRenderer.settingToUriString('example.stringSetting', 'three')); const verifyOriginalState = (actions: IAction[] | undefined): actions is IAction[] => { <del> assert.strictEqual(actions?.length, 2); </del> <ins> assert.strictEqual(actions?.length, 3); </ins> assert.strictEqual(actions[0].label, 'Set "Example: String Setting" to "three"'); assert.strictEqual(actions[1].label, 'View in Settings'); assert.strictEqual(configurationService.getValue('example.stringSetting'), 'two');

await actions[0].run(); assert.strictEqual(configurationService.getValue('example.stringSetting'), 'three'); const actionsUpdated = settingRenderer.getActions(uri); <del> assert.strictEqual(actionsUpdated?.length, 2); </del> <ins> assert.strictEqual(actionsUpdated?.length, 3); </ins> assert.strictEqual(actionsUpdated[0].label, 'Restore value of "Example: String Setting"'); assert.strictEqual(actions[1].label, 'View in Settings'); <ins> assert.strictEqual(actions[2].label, 'Copy Setting ID'); </ins> assert.strictEqual(configurationService.getValue('example.stringSetting'), 'three'); // Restore the value