Skip to content

Commit

Permalink
Use custom command to open docs
Browse files Browse the repository at this point in the history
* In some cases, `vscode.open` could cause the docs to open inside the editor as a tab.
  • Loading branch information
Discookie committed Aug 23, 2022
1 parent 391ac84 commit 39900d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/editor/navigation.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/views/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class ReportsView implements TreeDataProvider<ReportTreeItem> {
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]
};

Expand Down

0 comments on commit 39900d7

Please sign in to comment.