Skip to content

Commit 73cad51

Browse files
add text document Uri param to open text document command (#107)
and check current table view document Uri when that command is called without text document Uri to open a text document in editor
1 parent 1c71fbf commit 73cad51

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/commands/openTextDocument.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {
22
commands,
3-
ExtensionContext,
3+
window,
44
Disposable,
5+
ExtensionContext,
6+
Uri
57
} from 'vscode';
68

79
import { ViewCommands } from './viewCommands';
@@ -15,8 +17,17 @@ import { TableView } from '../views/tableView';
1517
*/
1618
export async function registerOpenTextDocumentCommand(context: ExtensionContext) {
1719
const openTextDocumentCommand: Disposable =
18-
commands.registerCommand(ViewCommands.openTextDocument, () => {
19-
commands.executeCommand(ViewCommands.vscodeOpen, TableView.currentView?.documentUri);
20+
commands.registerCommand(ViewCommands.openTextDocument, (textDocumentUri: Uri) => {
21+
if (!textDocumentUri && TableView.currentView?.documentUri) {
22+
// use current table view document uri
23+
textDocumentUri = TableView.currentView.documentUri;
24+
}
25+
26+
if (textDocumentUri) {
27+
// use built-in vscode open command to show text document in code editor
28+
commands.executeCommand(ViewCommands.vscodeOpen, TableView.currentView?.documentUri);
29+
}
2030
});
31+
2132
context.subscriptions.push(openTextDocumentCommand);
2233
}

0 commit comments

Comments
 (0)