Skip to content

Commit aee6884

Browse files
committed
feat(uri): add stub handler for vscode:// URIs
1 parent 456f9d2 commit aee6884

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { isReleaseVersion } from './shared/vscode/env'
6565
import { Commands, registerErrorHandler } from './shared/vscode/commands2'
6666
import { formatError, isUserCancelledError, ToolkitError, UnknownError } from './shared/errors'
6767
import { Logging } from './shared/logger/commands'
68+
import { UriHandler } from './shared/vscode/uriHandler'
6869
import { telemetry } from './shared/telemetry/telemetry'
6970

7071
let localize: nls.LocalizeFunc
@@ -123,6 +124,8 @@ export async function activate(context: vscode.ExtensionContext) {
123124
await globals.schemaService.start()
124125
awsFiletypes.activate()
125126

127+
context.subscriptions.push(vscode.window.registerUriHandler(new UriHandler()))
128+
126129
const extContext: ExtContext = {
127130
extensionContext: context,
128131
awsContext: awsContext,

src/shared/vscode/uriHandler.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*!
2+
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import { getLogger } from '../logger/logger'
8+
9+
import * as nls from 'vscode-nls'
10+
import { getIdeProperties } from '../extensionUtilities'
11+
12+
const localize = nls.loadMessageBundle()
13+
14+
export class UriHandler implements vscode.UriHandler {
15+
public constructor() {}
16+
17+
public async handleUri(uri: vscode.Uri): Promise<void> {
18+
getLogger().verbose(`UriHandler: received request on path "${uri.path}"`)
19+
const button = localize(
20+
'AWS.uriHandler.nohandler.button',
21+
'Show {0} Toolkit version',
22+
getIdeProperties().company
23+
)
24+
const p = vscode.window.showErrorMessage(
25+
localize(
26+
'AWS.uriHandler.nohandler',
27+
'This version of {0} Toolkit does not handle vscode:// URLs. Check your AWS Toolkit version.',
28+
getIdeProperties().company
29+
),
30+
'View AWS Toolkit version'
31+
)
32+
return p.then(selection => {
33+
if (selection === button) {
34+
vscode.commands.executeCommand('aws.aboutToolkit')
35+
}
36+
})
37+
}
38+
}

0 commit comments

Comments
 (0)