diff --git a/README.md b/README.md index 18eaae3..4242102 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ The hex editor can be set as the default editor for certain file types by using ], ``` +## Configuring the Data Inspector + +By default the data inspector has a dedicated activity bar entry on the left that appears when the hex editor is opened, causing the explorer or whatever side bar you had opened to be hidden. If preferred, the hex editor view can be dragged into another view if preferred by dragging the ⬡ icon onto one of the other views. + +This can be used in combination with the `hexeditor.dataInspector.autoReveal` setting to avoid revealing the side bar containing the data inspector all together. + ## Known Issues - Undoing a pending edit causes editor to get into a bad state [#161](https://github.com/microsoft/vscode-hexeditor/issues/161) diff --git a/package.json b/package.json index 6d688a3..0a8e151 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,11 @@ "minimum": 0, "default": 10, "description": "The max file size (in MB) that the editor will try to open before warning you." + }, + "hexeditor.dataInspector.autoReveal": { + "type": "boolean", + "default": true, + "description": "Whether to auto reveal the data inspector when the hex editor is opened." } } } @@ -68,7 +73,7 @@ "id": "hexExplorer", "title": "Hex Editor", "icon": "panel-icon.svg", - "when": "hexEditor:openEditor" + "when": "hexEditor:openEditor" } ] }, diff --git a/src/dataInspectorView.ts b/src/dataInspectorView.ts index f4d81cc..feeb593 100644 --- a/src/dataInspectorView.ts +++ b/src/dataInspectorView.ts @@ -60,12 +60,18 @@ export class DataInspectorView implements vscode.WebviewViewProvider { * @description Function to reveal the view panel * @param forceFocus Whether or not to force focus of the panel */ - public show(forceFocus?: boolean): void { - if (this._view && !forceFocus) { + public show(options?: { forceFocus?: boolean; autoReveal?: boolean }): void { + // Don't reveal the panel if configured not to + if (options?.autoReveal && !vscode.workspace.getConfiguration("hexeditor.dataInspector").get("autoReveal", false)) { + return; + } + + if (this._view && !options?.forceFocus) { this._view.show(); } else { vscode.commands.executeCommand(`${DataInspectorView.viewType}.focus`); } + // We attempt to send the last message, this prevents the inspector from coming up blank if (this._lastMessage) { this._view?.webview.postMessage(this._lastMessage); diff --git a/src/hexEditorProvider.ts b/src/hexEditorProvider.ts index 30ad6f7..b2cfa48 100644 --- a/src/hexEditorProvider.ts +++ b/src/hexEditorProvider.ts @@ -46,7 +46,9 @@ export class HexEditorProvider implements vscode.CustomEditorProvider { // Tell VS Code that the document has been edited by the user. this._onDidChangeCustomDocument.fire({ @@ -130,7 +132,10 @@ export class HexEditorProvider implements vscode.CustomEditorProvider