Skip to content

Commit fe24c46

Browse files
authored
bugfix: Cannot open binary file from project explorer (#315)
1 parent ea43694 commit fe24c46

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export namespace Commands {
6666

6767
export const VSCODE_OPEN_FOLDER = "vscode.openFolder";
6868

69+
export const VSCODE_OPEN = "vscode.open";
70+
6971
export const JAVA_BUILD_WORKSPACE = "java.workspace.compile";
7072

7173
export const JAVA_CLEAN_WORKSPACE = "java.clean.workspace";

src/views/dependencyDataProvider.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as _ from "lodash";
55
import {
66
commands, Event, EventEmitter, ExtensionContext, extensions, ProviderResult,
7-
Range, Selection, TextEditorRevealType, TreeDataProvider, TreeItem, Uri, window, workspace,
7+
Range, TreeDataProvider, TreeItem, Uri, window, workspace,
88
} from "vscode";
99
import { instrumentOperation, instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
1010
import { Commands } from "../commands";
@@ -42,8 +42,10 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
4242
commands.executeCommand("copyFilePath", Uri.parse(node.uri))));
4343
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_COPY_RELATIVE_FILE_PATH, (node: INodeData) =>
4444
commands.executeCommand("copyRelativeFilePath", Uri.parse(node.uri))));
45-
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OPEN_FILE, (uri) => this.openFile(uri)));
46-
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OUTLINE, (uri, range) => this.goToOutline(uri, range)));
45+
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OPEN_FILE, (uri) =>
46+
commands.executeCommand(Commands.VSCODE_OPEN, Uri.parse(uri))));
47+
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OUTLINE, (uri, range) =>
48+
window.showTextDocument(Uri.parse(uri), { selection: range })));
4749
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_BUILD_WORKSPACE, () =>
4850
commands.executeCommand(Commands.JAVA_BUILD_WORKSPACE)));
4951
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_CLEAN_WORKSPACE, () =>
@@ -81,20 +83,6 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
8183
this._refreshDelayTrigger = _.debounce(this.doRefresh, wait);
8284
}
8385

84-
public openFile(uri: string) {
85-
return workspace.openTextDocument(Uri.parse(uri)).then((res) => {
86-
return window.showTextDocument(res);
87-
});
88-
}
89-
90-
public goToOutline(uri: string, range: Range): Thenable<{}> {
91-
return this.openFile(uri).then((editor) => {
92-
editor.revealRange(range, TextEditorRevealType.Default);
93-
editor.selection = new Selection(range.start, range.start);
94-
return commands.executeCommand("workbench.action.focusActiveEditorGroup");
95-
});
96-
}
97-
9886
public getTreeItem(element: ExplorerNode): TreeItem | Thenable<TreeItem> {
9987
return element.getTreeItem();
10088
}

0 commit comments

Comments
 (0)