Skip to content

Commit 716453c

Browse files
committed
refactor: openSettings
1 parent 81f88e4 commit 716453c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/core/src/codewhisperer/activation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { debounceStartSecurityScan } from './commands/startSecurityScan'
6969
import { securityScanLanguageContext } from './util/securityScanLanguageContext'
7070
import { registerWebviewErrorHandler } from '../webviews/server'
7171
import { logAndShowWebviewError } from '../shared/utilities/logAndShowUtils'
72+
import { openSettings } from '../shared/settings'
7273

7374
let localize: nls.LocalizeFunc
7475

@@ -190,7 +191,7 @@ export async function activate(context: ExtContext): Promise<void> {
190191
`@id:amazonQ.showInlineCodeSuggestionsWithCodeReferences`
191192
)
192193
} else {
193-
await vscode.commands.executeCommand('workbench.action.openSettings', `amazonQ`)
194+
await openSettings('amazonQ')
194195
}
195196
}),
196197
Commands.register('aws.amazonq.refreshAnnotation', async (forceProceed: boolean = false) => {

packages/core/src/shared/settings.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,16 @@ export async function migrateSetting<T, U = T>(
894894
await migrateForScope(vscode.ConfigurationTarget.Global)
895895
}
896896

897+
/** Opens the settings UI filtered by the given prefix. */
898+
export async function openSettings(prefix: string): Promise<void> {
899+
await vscode.commands.executeCommand('workbench.action.openSettings', prefix)
900+
}
901+
897902
/**
898903
* Opens the settings UI at the specified key.
899904
*
900905
* This only works for keys that are considered "top-level", e.g. keys of {@link settingsProps}.
901906
*/
902-
export async function openSettings<K extends keyof SettingsProps>(key: K): Promise<void> {
907+
export async function openSettingsId<K extends keyof SettingsProps>(key: K): Promise<void> {
903908
await vscode.commands.executeCommand('workbench.action.openSettings', `@id:${key}`)
904909
}

packages/core/src/shared/telemetry/activation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { AwsContext } from '../awsContext'
1313
import { DefaultTelemetryService } from './telemetryService'
1414
import { getLogger } from '../logger'
1515
import { getComputeRegion, isAmazonQ, isCloud9, productName } from '../extensionUtilities'
16-
import { openSettings, Settings } from '../settings'
16+
import { openSettingsId, Settings } from '../settings'
1717
import { TelemetryConfig, setupTelemetryId } from './util'
1818
import { isAutomation, isReleaseVersion } from '../vscode/env'
1919
import { AWSProduct } from './clienttelemetry'
@@ -133,7 +133,7 @@ export async function handleTelemetryNoticeResponse(
133133
// noticeResponseOk is a no-op
134134

135135
if (response === noticeResponseViewSettings) {
136-
await openSettings(isAmazonQ() ? 'amazonQ.telemetry' : 'aws.telemetry')
136+
await openSettingsId(isAmazonQ() ? 'amazonQ.telemetry' : 'aws.telemetry')
137137
}
138138
} catch (err) {
139139
getLogger().error('Error while handling response from telemetry notice: %O', err as Error)

0 commit comments

Comments
 (0)