diff --git a/package.json b/package.json index 1acf454..2eeca2b 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,12 @@ } ], "commands": [ + { + "command": "hexEditor.reopenFile", + "category": "%name%", + "title": "%hexEditor.reopenFile%", + "icon": "$(file-binary)" + }, { "command": "hexEditor.openFile", "category": "%name%", @@ -198,7 +204,7 @@ ], "editor/title": [ { - "command": "hexEditor.openFile", + "command": "hexEditor.reopenFile", "group": "navigation@1", "when": "activeEditor && config.hexeditor.showOpenFileButton" } @@ -221,6 +227,11 @@ } ], "explorer/context": [ + { + "command": "hexEditor.openFile", + "group": "2_open", + "when": "!explorerResourceIsFolder" + }, { "command": "hexEditor.compareSelected", "group": "3_compare@30", diff --git a/package.nls.json b/package.nls.json index 84ef5ed..fda59bd 100644 --- a/package.nls.json +++ b/package.nls.json @@ -9,7 +9,8 @@ "hexeditor.columnWidth": "The number of bytes per row to show in the editor.", "hexeditor.showDecodedText": "Whether decoded text should be shown in the editor.", "hexeditor.showOpenFileButton": "Show Hex Editor button in editor menu.", - "hexEditor.openFile": "Open Active File in Hex Editor", + "hexEditor.reopenFile": "Open Active File in Hex Editor", + "hexEditor.openFile": "Open in Hex Editor", "hexEditor.goToOffset": "Go To Offset", "hexEditor.selectBetweenOffsets": "Select Between Offsets", "hexEditor.copyAs": "Copy As...", diff --git a/src/extension.ts b/src/extension.ts index 588fe77..43f0a06 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -32,7 +32,13 @@ function reopenWithHexEditor() { uri: vscode.Uri | undefined; }; if (activeTabInput.uri) { - vscode.commands.executeCommand("vscode.openWith", activeTabInput.uri, "hexEditor.hexedit"); + openWithHexEditor(activeTabInput.uri); + } +} + +function openWithHexEditor(resource: vscode.Uri | undefined) { + if (resource) { + vscode.commands.executeCommand("vscode.openWith", resource, "hexEditor.hexedit"); } } @@ -53,9 +59,13 @@ export async function activate(context: vscode.ExtensionContext) { const telemetryReporter = new TelemetryReporter(configValues.aiKey); context.subscriptions.push(telemetryReporter); + const reopenWithCommand = vscode.commands.registerCommand( + "hexEditor.reopenFile", + reopenWithHexEditor, + ); const openWithCommand = vscode.commands.registerCommand( "hexEditor.openFile", - reopenWithHexEditor, + openWithHexEditor, ); const goToOffsetCommand = vscode.commands.registerCommand("hexEditor.goToOffset", () => { const first = registry.activeMessaging[Symbol.iterator]().next(); @@ -128,6 +138,7 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(selectBetweenOffsetsCommand); context.subscriptions.push(copyAsCommand); context.subscriptions.push(switchEditModeCommand); + context.subscriptions.push(reopenWithCommand); context.subscriptions.push(openWithCommand); context.subscriptions.push(telemetryReporter); context.subscriptions.push(copyOffsetAsDec, copyOffsetAsHex);