From 39900d750786f7eac9b5d5ca36463a47939fa08a Mon Sep 17 00:00:00 2001 From: Discookie Date: Tue, 23 Aug 2022 15:12:19 +0200 Subject: [PATCH] Use custom command to open docs * In some cases, `vscode.open` could cause the docs to open inside the editor as a tab. --- src/editor/navigation.ts | 11 ++++++++++- src/sidebar/views/reports.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/editor/navigation.ts b/src/editor/navigation.ts index 2f1adcb..f0ccee0 100644 --- a/src/editor/navigation.ts +++ b/src/editor/navigation.ts @@ -1,4 +1,4 @@ -import { ExtensionContext, Position, Range, Uri, commands, window } from 'vscode'; +import { ExtensionContext, Position, Range, Uri, commands, env, window } from 'vscode'; import { ExtensionApi } from '../backend/api'; import { DiagnosticReport } from '../backend/types'; @@ -12,6 +12,15 @@ export class NavigationHandler { ctx.subscriptions.push(commands.registerCommand('codechecker.editor.jumpToStep', this.jumpToStep, this)); ctx.subscriptions.push(commands.registerCommand('codechecker.editor.nextStep', this.nextStep, this)); ctx.subscriptions.push(commands.registerCommand('codechecker.editor.previousStep', this.previousStep, this)); + ctx.subscriptions.push(commands.registerCommand('codechecker.editor.openDocs', this.openDocs, this)); + } + + openDocs(docUrl: Uri | string) { + if (typeof docUrl === 'string') { + docUrl = Uri.parse(docUrl); + } + + void env.openExternal(docUrl); } onDiagnosticsUpdated() { diff --git a/src/sidebar/views/reports.ts b/src/sidebar/views/reports.ts index 0c319b7..8421a81 100644 --- a/src/sidebar/views/reports.ts +++ b/src/sidebar/views/reports.ts @@ -197,7 +197,7 @@ export class ReportsView implements TreeDataProvider { const goToDocsItem = new ReportTreeItem('openDocs', 'Go to checker documentation', new ThemeIcon('book')); goToDocsItem.command = { title: 'openDocs', - command: 'vscode.open', + command: 'codechecker.editor.openDocs', arguments: [docUrl] };