From ac1323c9e745bc1b4ef1d44da3d283cc6d30ca76 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Thu, 31 Aug 2023 14:33:22 -0500 Subject: [PATCH 01/12] add configuration and messaging, rename to wordsPerGroup --- package.json | 43 +++++++++++++++++++++-- src/common/messaging.ts | 3 ++ src/plugin/manifest.ts | 9 +++++ src/plugin/memory-webview-main.ts | 36 +++++++++++++++++-- src/webview/components/memory-widget.tsx | 8 ++--- src/webview/components/options-widget.tsx | 8 ++--- src/webview/utils/view-types.ts | 7 ++++ 7 files changed, 101 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 5eac926..8474610 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,11 @@ "items": { "type": "string" }, - "default": [ "gdb", "embedded-debug", "arm-debug" ], + "default": [ + "gdb", + "embedded-debug", + "arm-debug" + ], "description": "C-based debuggers to activate (requires debug session restart)" }, "memory-inspector.refreshOnStop": { @@ -137,6 +141,41 @@ ], "default": "on", "description": "Refresh memory views when debugger stops" + }, + "memory-inspector.wordsPerGroup": { + "type": "number", + "enum": [ + 1, + 2, + 4, + 8, + 16 + ], + "default": 1, + "description": "Default words per group" + }, + "memory-inspector.groupsPerRow": { + "type": "number", + "enum": [ + 1, + 2, + 4, + 8, + 16, + 32 + ], + "default": 4, + "description": "Default groups per row" + }, + "memory-inspector.showVariablesColumn": { + "type": "boolean", + "default": false, + "description": "Show variables column?" + }, + "memory-inspector.showAsciiColumn": { + "type": "boolean", + "default": false, + "description": "Show ASCII column?" } } } @@ -148,4 +187,4 @@ "extensionKind": [ "ui" ] -} +} \ No newline at end of file diff --git a/src/common/messaging.ts b/src/common/messaging.ts index 166b40b..4023d9a 100644 --- a/src/common/messaging.ts +++ b/src/common/messaging.ts @@ -17,12 +17,15 @@ import type { DebugProtocol } from '@vscode/debugprotocol'; import type { NotificationType, RequestType } from 'vscode-messenger-common'; import type { VariableRange } from './memory-range'; +import { MemoryInspectorConfiguration } from '../webview/utils/view-types'; export type MemoryReadResult = DebugProtocol.ReadMemoryResponse['body']; export type MemoryWriteResult = DebugProtocol.WriteMemoryResponse['body']; export const readyType: NotificationType = { method: 'ready' }; export const logMessageType: RequestType = { method: 'logMessage' }; +export const getConfigurationType: RequestType = { method: 'getConfiguration' }; +export const configurationDidChangeType: NotificationType = { method: 'configurationDidChangeType' }; export const setOptionsType: RequestType, void> = { method: 'setOptions' }; export const readMemoryType: RequestType = { method: 'readMemory' }; export const writeMemoryType: RequestType = { method: 'writeMemory' }; diff --git a/src/plugin/manifest.ts b/src/plugin/manifest.ts index f0586f6..6960e27 100644 --- a/src/plugin/manifest.ts +++ b/src/plugin/manifest.ts @@ -22,3 +22,12 @@ export const CONFIG_DEBUG_TYPES = 'debugTypes'; export const DEFAULT_DEBUG_TYPES = [ 'gdb', 'embedded-debug', 'arm-debug' ]; export const CONFIG_REFRESH_ON_STOP = 'refreshOnStop'; export const DEFAULT_REFRESH_ON_STOP = 'on'; + +export const CONFIG_WORDS_PER_GROUP = 'wordsPerGroup'; +export const DEFAULT_WORDS_PER_GROUP = 1; +export const CONFIG_GROUPS_PER_ROW = 'groupsPerRow'; +export const DEFAULT_GROUPS_PER_ROW = 4; +export const CONFIG_SHOW_VARIABLES_COLUMN = 'showVariablesColumn'; +export const DEFAULT_SHOW_VARIABLES_COLUMN = false; +export const CONFIG_SHOW_ASCII_COLUMN = 'showasciiColumn'; +export const DEFAULT_SHOW_ASCII_COLUMN = false; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index bd779dd..890fa4e 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -18,7 +18,7 @@ import * as vscode from 'vscode'; import type { DebugProtocol } from '@vscode/debugprotocol'; import * as manifest from './manifest'; import { Messenger } from 'vscode-messenger'; -import { WebviewIdMessageParticipant } from 'vscode-messenger-common'; +import { MessageParticipant, WebviewIdMessageParticipant } from 'vscode-messenger-common'; import { readyType, logMessageType, @@ -27,11 +27,14 @@ import { writeMemoryType, MemoryReadResult, MemoryWriteResult, - getVariables + getVariables, + getConfigurationType, + configurationDidChangeType } from '../common/messaging'; import { MemoryProvider } from './memory-provider'; import { outputChannelLogger } from './logger'; import { VariableRange } from '../common/memory-range'; +import { MemoryInspectorConfiguration } from '../webview/utils/view-types'; interface Variable { name: string; @@ -138,14 +141,17 @@ export class MemoryWebview { const disposables = [ this.messenger.onNotification(readyType, () => this.refresh(participant, options), { sender: participant }), this.messenger.onRequest(logMessageType, message => outputChannelLogger.info('[webview]:', message), { sender: participant }), + this.messenger.onRequest(getConfigurationType, () => this.getConfiguration(), { sender: participant }), this.messenger.onRequest(readMemoryType, request => this.readMemory(request), { sender: participant }), this.messenger.onRequest(writeMemoryType, request => this.writeMemory(request), { sender: participant }), this.messenger.onRequest(getVariables, request => this.getVariables(request), { sender: participant }), + this.messenger.onRequest(getVariables, request => this.getVariables(request), { sender: participant }), this.memoryProvider.onDidStopDebug(() => { if (this.refreshOnStop === RefreshEnum.on) { this.refresh(participant); } - }) + }), + this.onConfigurationChanged(participant), ]; panel.onDidDispose(() => disposables.forEach(disposible => disposible.dispose())); @@ -155,6 +161,30 @@ export class MemoryWebview { this.messenger.sendRequest(setOptionsType, participant, options); } + protected getConfiguration(): MemoryInspectorConfiguration { + const memoryInspectorConfiguration = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME); + const wordsPerGroup = memoryInspectorConfiguration.get(manifest.CONFIG_WORDS_PER_GROUP) || manifest.DEFAULT_WORDS_PER_GROUP; + const groupsPerRow = memoryInspectorConfiguration.get(manifest.CONFIG_GROUPS_PER_ROW) || manifest.DEFAULT_GROUPS_PER_ROW; + const showVariablesColumn = memoryInspectorConfiguration.get(manifest.CONFIG_SHOW_VARIABLES_COLUMN) || manifest.DEFAULT_SHOW_VARIABLES_COLUMN; + const showAsciiColumn = memoryInspectorConfiguration.get(manifest.CONFIG_SHOW_ASCII_COLUMN) || manifest.DEFAULT_SHOW_ASCII_COLUMN; + return { wordsPerGroup, groupsPerRow, showAsciiColumn, showVariablesColumn }; + } + + protected onConfigurationChanged(participant: MessageParticipant): vscode.Disposable { + const VIEW_CONFIGURATION_OPTIONS = [ + manifest.CONFIG_WORDS_PER_GROUP, + manifest.CONFIG_GROUPS_PER_ROW, + manifest.CONFIG_SHOW_ASCII_COLUMN, + manifest.CONFIG_SHOW_VARIABLES_COLUMN, + ]; + return vscode.workspace.onDidChangeConfiguration(e => { + if (VIEW_CONFIGURATION_OPTIONS.some(configurationOption => e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configurationOption}`))) { + const configuration = this.getConfiguration(); + this.messenger.sendNotification(configurationDidChangeType, participant, configuration); + } + }); + } + protected async readMemory(request: DebugProtocol.ReadMemoryArguments): Promise { try { return await this.memoryProvider.readMemory(request); diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index 3070c7f..8c355f1 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -36,14 +36,14 @@ interface MemoryWidgetProps { interface MemoryWidgetState { endianness: Endianness; wordSize: number; - bytesPerGroup: number; + wordsPerGroup: number; groupsPerRow: number; } const defaultOptions: MemoryWidgetState = { endianness: Endianness.Little, wordSize: 8, - bytesPerGroup: 1, + wordsPerGroup: 1, groupsPerRow: 4, }; @@ -62,7 +62,7 @@ export class MemoryWidget extends React.Component ; diff --git a/src/webview/components/options-widget.tsx b/src/webview/components/options-widget.tsx index 456dbb1..8f8190d 100644 --- a/src/webview/components/options-widget.tsx +++ b/src/webview/components/options-widget.tsx @@ -36,7 +36,7 @@ const enum InputId { Address = 'address', Offset = 'offset', Length = 'length', - BytesPerGroup = 'bytes-per-group', + wordsPerGroup = 'bytes-per-group', GroupsPerRow = 'groups-per-row', } @@ -99,8 +99,8 @@ export class OptionsWidget extends React.Component
- - + + 1 2 4 @@ -140,7 +140,7 @@ export class OptionsWidget extends React.Component Date: Thu, 31 Aug 2023 16:53:00 -0500 Subject: [PATCH 02/12] add configuration --- package.json | 10 +--- src/common/messaging.ts | 9 ++- src/plugin/manifest.ts | 6 +- src/plugin/memory-webview-main.ts | 70 +++++++++++++++++------ src/webview/columns/ascii-column.ts | 2 +- src/webview/components/memory-table.tsx | 4 +- src/webview/components/memory-widget.tsx | 16 ++++-- src/webview/components/options-widget.tsx | 19 ++++-- src/webview/memory-webview-view.tsx | 27 +++++++-- src/webview/utils/view-types.ts | 19 ++++-- 10 files changed, 127 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 8474610..6afc5c0 100644 --- a/package.json +++ b/package.json @@ -122,11 +122,7 @@ "items": { "type": "string" }, - "default": [ - "gdb", - "embedded-debug", - "arm-debug" - ], + "default": [ "gdb", "embedded-debug", "arm-debug" ], "description": "C-based debuggers to activate (requires debug session restart)" }, "memory-inspector.refreshOnStop": { @@ -167,12 +163,12 @@ "default": 4, "description": "Default groups per row" }, - "memory-inspector.showVariablesColumn": { + "memory-inspector.variablesVisible": { "type": "boolean", "default": false, "description": "Show variables column?" }, - "memory-inspector.showAsciiColumn": { + "memory-inspector.asciiVisible": { "type": "boolean", "default": false, "description": "Show ASCII column?" diff --git a/src/common/messaging.ts b/src/common/messaging.ts index 4023d9a..0abadd4 100644 --- a/src/common/messaging.ts +++ b/src/common/messaging.ts @@ -17,15 +17,18 @@ import type { DebugProtocol } from '@vscode/debugprotocol'; import type { NotificationType, RequestType } from 'vscode-messenger-common'; import type { VariableRange } from './memory-range'; -import { MemoryInspectorConfiguration } from '../webview/utils/view-types'; +import { ColumnVisibilityStatus, MemoryDisplayConfiguration, MemoryDisplayConfigurationChangeRequest } from '../webview/utils/view-types'; export type MemoryReadResult = DebugProtocol.ReadMemoryResponse['body']; export type MemoryWriteResult = DebugProtocol.WriteMemoryResponse['body']; export const readyType: NotificationType = { method: 'ready' }; export const logMessageType: RequestType = { method: 'logMessage' }; -export const getConfigurationType: RequestType = { method: 'getConfiguration' }; -export const configurationDidChangeType: NotificationType = { method: 'configurationDidChangeType' }; +export const getMemoryDisplayConfigurationType: RequestType = { method: 'getMemoryDisplayConfiguration' }; +export const setMemoryDisplayConfigurationType: NotificationType = { method: 'setMemoryDisplayConfiguration' }; +export const memoryDisplayConfigurationChangedType: NotificationType = { method: 'memoryDisplayConfigurationChanged' }; +export const getColumnsVisibility: RequestType = { method: 'getColumnsVisibility' }; +export const columnVisibilityType: NotificationType = { method: 'columnVisibility' }; export const setOptionsType: RequestType, void> = { method: 'setOptions' }; export const readMemoryType: RequestType = { method: 'readMemory' }; export const writeMemoryType: RequestType = { method: 'writeMemory' }; diff --git a/src/plugin/manifest.ts b/src/plugin/manifest.ts index 6960e27..a95d20a 100644 --- a/src/plugin/manifest.ts +++ b/src/plugin/manifest.ts @@ -27,7 +27,5 @@ export const CONFIG_WORDS_PER_GROUP = 'wordsPerGroup'; export const DEFAULT_WORDS_PER_GROUP = 1; export const CONFIG_GROUPS_PER_ROW = 'groupsPerRow'; export const DEFAULT_GROUPS_PER_ROW = 4; -export const CONFIG_SHOW_VARIABLES_COLUMN = 'showVariablesColumn'; -export const DEFAULT_SHOW_VARIABLES_COLUMN = false; -export const CONFIG_SHOW_ASCII_COLUMN = 'showasciiColumn'; -export const DEFAULT_SHOW_ASCII_COLUMN = false; +export const CONFIG_SHOW_VARIABLES_COLUMN = 'variablesVisible'; +export const CONFIG_SHOW_ASCII_COLUMN = 'asciiVisible'; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index 890fa4e..9805836 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -28,13 +28,16 @@ import { MemoryReadResult, MemoryWriteResult, getVariables, - getConfigurationType, - configurationDidChangeType + memoryDisplayConfigurationChangedType, + columnVisibilityType, + setMemoryDisplayConfigurationType, + getColumnsVisibility, + getMemoryDisplayConfigurationType, } from '../common/messaging'; import { MemoryProvider } from './memory-provider'; import { outputChannelLogger } from './logger'; import { VariableRange } from '../common/memory-range'; -import { MemoryInspectorConfiguration } from '../webview/utils/view-types'; +import { ColumnVisibilityStatus, MemoryDisplayConfiguration as MemoryDisplayConfiguration } from '../webview/utils/view-types'; interface Variable { name: string; @@ -141,47 +144,82 @@ export class MemoryWebview { const disposables = [ this.messenger.onNotification(readyType, () => this.refresh(participant, options), { sender: participant }), this.messenger.onRequest(logMessageType, message => outputChannelLogger.info('[webview]:', message), { sender: participant }), - this.messenger.onRequest(getConfigurationType, () => this.getConfiguration(), { sender: participant }), this.messenger.onRequest(readMemoryType, request => this.readMemory(request), { sender: participant }), this.messenger.onRequest(writeMemoryType, request => this.writeMemory(request), { sender: participant }), this.messenger.onRequest(getVariables, request => this.getVariables(request), { sender: participant }), - this.messenger.onRequest(getVariables, request => this.getVariables(request), { sender: participant }), + this.messenger.onRequest(getMemoryDisplayConfigurationType, () => this.getMemoryDisplayConfiguration(), { sender: participant }), + this.messenger.onRequest(getColumnsVisibility, () => this.getColumnConfigurations(), { sender: participant }), + this.messenger.onNotification(setMemoryDisplayConfigurationType, request => this.setConfiguration(request), { sender: participant }), + this.messenger.onNotification(columnVisibilityType, request => this.handleColumnToggled(request), { sender: participant }), + this.memoryProvider.onDidStopDebug(() => { if (this.refreshOnStop === RefreshEnum.on) { this.refresh(participant); } }), - this.onConfigurationChanged(participant), + this.onMemoryDisplayConfigurationChanged(participant), + this.onColumnVisibilityConfigurationChanged(participant), ]; panel.onDidDispose(() => disposables.forEach(disposible => disposible.dispose())); } + protected handleColumnToggled(request: ColumnVisibilityStatus): void { + const { id, active: visible } = request; + vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).update(`${id}Visible`, visible, vscode.ConfigurationTarget.Global); + } + + protected setConfiguration(request: { id: string, value: unknown }): void { + const { id, value } = request; + vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).update(id, value, vscode.ConfigurationTarget.Global); + } + protected async refresh(participant: WebviewIdMessageParticipant, options?: Partial): Promise { this.messenger.sendRequest(setOptionsType, participant, options); } - protected getConfiguration(): MemoryInspectorConfiguration { + protected getMemoryDisplayConfiguration(): MemoryDisplayConfiguration { const memoryInspectorConfiguration = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME); const wordsPerGroup = memoryInspectorConfiguration.get(manifest.CONFIG_WORDS_PER_GROUP) || manifest.DEFAULT_WORDS_PER_GROUP; const groupsPerRow = memoryInspectorConfiguration.get(manifest.CONFIG_GROUPS_PER_ROW) || manifest.DEFAULT_GROUPS_PER_ROW; - const showVariablesColumn = memoryInspectorConfiguration.get(manifest.CONFIG_SHOW_VARIABLES_COLUMN) || manifest.DEFAULT_SHOW_VARIABLES_COLUMN; - const showAsciiColumn = memoryInspectorConfiguration.get(manifest.CONFIG_SHOW_ASCII_COLUMN) || manifest.DEFAULT_SHOW_ASCII_COLUMN; - return { wordsPerGroup, groupsPerRow, showAsciiColumn, showVariablesColumn }; + return { wordsPerGroup, groupsPerRow }; } - protected onConfigurationChanged(participant: MessageParticipant): vscode.Disposable { - const VIEW_CONFIGURATION_OPTIONS = [ + protected onMemoryDisplayConfigurationChanged(participant: MessageParticipant): vscode.Disposable { + const memoryDisplayConfigurations = [ manifest.CONFIG_WORDS_PER_GROUP, manifest.CONFIG_GROUPS_PER_ROW, + ]; + return vscode.workspace.onDidChangeConfiguration(e => { + if (memoryDisplayConfigurations.some(configurationOption => e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configurationOption}`))) { + const configuration = this.getMemoryDisplayConfiguration(); + this.messenger.sendNotification(memoryDisplayConfigurationChangedType, participant, configuration); + } + }); + } + + protected onColumnVisibilityConfigurationChanged(participant: MessageParticipant): vscode.Disposable { + const columnConfigurations = [ manifest.CONFIG_SHOW_ASCII_COLUMN, manifest.CONFIG_SHOW_VARIABLES_COLUMN, ]; return vscode.workspace.onDidChangeConfiguration(e => { - if (VIEW_CONFIGURATION_OPTIONS.some(configurationOption => e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configurationOption}`))) { - const configuration = this.getConfiguration(); - this.messenger.sendNotification(configurationDidChangeType, participant, configuration); - } + columnConfigurations.forEach(configuration => { + if (e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configuration}`)) { + const [id] = configuration.split('Visible'); + const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(configuration) ?? true; + this.messenger.sendNotification(columnVisibilityType, participant, { id, active }); + } + }); + }); + } + + protected getColumnConfigurations(): ColumnVisibilityStatus[] { + const COLUMN_CONFIGURATIONS = [manifest.CONFIG_SHOW_VARIABLES_COLUMN, manifest.CONFIG_SHOW_ASCII_COLUMN]; + return COLUMN_CONFIGURATIONS.map(configuration => { + const [id] = configuration.split('Visible'); + const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(configuration) ?? false; + return { id, active }; }); } diff --git a/src/webview/columns/ascii-column.ts b/src/webview/columns/ascii-column.ts index 886d5bc..319d45a 100644 --- a/src/webview/columns/ascii-column.ts +++ b/src/webview/columns/ascii-column.ts @@ -16,8 +16,8 @@ import { ReactNode } from 'react'; import { BigIntMemoryRange, toOffset } from '../../common/memory-range'; -import { Memory } from '../utils/view-types'; import { ColumnContribution, TableRenderOptions } from './column-contribution-service'; +import { Memory } from '../utils/view-types'; function isPrintableAsAscii(input: number): boolean { return input >= 32 && input < (128 - 1); diff --git a/src/webview/components/memory-table.tsx b/src/webview/components/memory-table.tsx index 4d2d2d4..a265ade 100644 --- a/src/webview/components/memory-table.tsx +++ b/src/webview/components/memory-table.tsx @@ -20,11 +20,11 @@ import { VSCodeDataGridRow, VSCodeDataGridCell } from '@vscode/webview-ui-toolkit/react'; -import { Decoration, Memory, StylableNodeAttributes } from '../utils/view-types'; +import { Decoration, Memory, MemoryDisplayConfiguration, StylableNodeAttributes } from '../utils/view-types'; import { toHexStringWithRadixMarker } from '../../common/memory-range'; import { TableRenderOptions } from '../columns/column-contribution-service'; -interface MemoryTableProps extends TableRenderOptions { +interface MemoryTableProps extends TableRenderOptions, MemoryDisplayConfiguration { memory?: Memory; decorations: Decoration[]; } diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index 8c355f1..fee257e 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -18,7 +18,10 @@ import { DebugProtocol } from '@vscode/debugprotocol'; import React from 'react'; import { MemoryTable } from './memory-table'; import { OptionsWidget } from './options-widget'; -import { Decoration, Endianness, Memory } from '../utils/view-types'; +import { Decoration, Endianness, Memory, MemoryDisplayConfiguration } from '../utils/view-types'; +import { messenger } from '../view-messenger'; +import { getMemoryDisplayConfigurationType, memoryDisplayConfigurationChangedType } from '../../common/messaging'; +import { HOST_EXTENSION } from 'vscode-messenger-common'; import { ColumnStatus } from '../columns/column-contribution-service'; interface MemoryWidgetProps { @@ -33,11 +36,9 @@ interface MemoryWidgetProps { toggleColumn(id: string, active: boolean): void; } -interface MemoryWidgetState { +interface MemoryWidgetState extends MemoryDisplayConfiguration { endianness: Endianness; wordSize: number; - wordsPerGroup: number; - groupsPerRow: number; } const defaultOptions: MemoryWidgetState = { @@ -53,6 +54,13 @@ export class MemoryWidget extends React.Component this.setState(configuration)); + messenger.sendRequest(getMemoryDisplayConfigurationType, HOST_EXTENSION, undefined).then(configuration => { + this.setState(configuration); + }); + } + override render(): React.ReactNode { return <> { +export interface OptionsWidgetProps extends TableRenderOptions, Required, MemoryDisplayConfiguration { updateRenderOptions: (options: Partial) => void; updateMemoryArguments: (memoryArguments: Partial) => void; refreshMemory: () => void; @@ -99,7 +102,7 @@ export class OptionsWidget extends React.Component
- + 1 2 @@ -140,11 +143,15 @@ export class OptionsWidget extends React.Component this.doToggleRenderOptions(); protected doToggleRenderOptions(): void { diff --git a/src/webview/memory-webview-view.tsx b/src/webview/memory-webview-view.tsx index f306e75..af5aa51 100644 --- a/src/webview/memory-webview-view.tsx +++ b/src/webview/memory-webview-view.tsx @@ -21,13 +21,15 @@ import { readyType, logMessageType, setOptionsType, - readMemoryType + readMemoryType, + columnVisibilityType, + getColumnsVisibility } from '../common/messaging'; import type { DebugProtocol } from '@vscode/debugprotocol'; -import { Decoration, Memory, MemoryState } from './utils/view-types'; +import { ColumnVisibilityStatus, Decoration, Memory, MemoryState } from './utils/view-types'; import { MemoryWidget } from './components/memory-widget'; import { messenger } from './view-messenger'; -import { columnContributionService, ColumnStatus } from './columns/column-contribution-service'; +import { ColumnStatus, columnContributionService } from './columns/column-contribution-service'; import { decorationService } from './decorations/decoration-service'; import { variableDecorator } from './variables/variable-decorations'; import { AsciiColumn } from './columns/ascii-column'; @@ -39,6 +41,9 @@ export interface MemoryAppState extends MemoryState { columns: ColumnStatus[]; } +export const DEFAULT_WORDS_PER_GROUP = 1; +export const DEFAULT_GROUPS_PER_ROW = 4; + class App extends React.Component<{}, MemoryAppState> { public constructor(props: {}) { @@ -61,6 +66,11 @@ class App extends React.Component<{}, MemoryAppState> { public componentDidMount(): void { messenger.onRequest(setOptionsType, options => this.setOptions(options)); messenger.sendNotification(readyType, HOST_EXTENSION, undefined); + messenger.onNotification(columnVisibilityType, request => this.handleColumnVisibilityChanged(request)); + messenger.sendRequest(getColumnsVisibility, HOST_EXTENSION, undefined).then(columnsVisibility => { + columnsVisibility.forEach(columnVisibility => this.handleColumnVisibilityChanged(columnVisibility)); + }); + } public render(): React.ReactNode { @@ -77,6 +87,12 @@ class App extends React.Component<{}, MemoryAppState> { />; } + protected async handleColumnVisibilityChanged(request: ColumnVisibilityStatus): Promise { + const { active, id } = request; + const columns = active ? await columnContributionService.show(id, this.state) : columnContributionService.hide(id); + this.setState({ columns }); + } + protected updateMemoryState = (newState: Partial) => this.setState(prevState => ({ ...prevState, ...newState })); protected async setOptions(options?: Partial): Promise { @@ -114,9 +130,8 @@ class App extends React.Component<{}, MemoryAppState> { protected toggleColumn = (id: string, active: boolean): void => { this.doToggleColumn(id, active); }; - protected async doToggleColumn(id: string, active: boolean): Promise { - const columns = active ? await columnContributionService.show(id, this.state) : columnContributionService.hide(id); - this.setState({ columns }); + protected doToggleColumn(id: string, active: boolean): void { + messenger.sendNotification(columnVisibilityType, HOST_EXTENSION, { id, active }); } } diff --git a/src/webview/utils/view-types.ts b/src/webview/utils/view-types.ts index ce72717..3097841 100644 --- a/src/webview/utils/view-types.ts +++ b/src/webview/utils/view-types.ts @@ -18,6 +18,7 @@ import type { DebugProtocol } from '@vscode/debugprotocol'; import type * as React from 'react'; import { areRangesEqual, BigIntMemoryRange } from '../../common/memory-range'; import deepequal from 'fast-deep-equal'; +import { TableRenderOptions } from '../columns/column-contribution-service'; export enum Endianness { Little = 'Little Endian', @@ -29,11 +30,9 @@ export interface Memory { bytes: Uint8Array; } -export interface SerializedTableRenderOptions { +export interface SerializedTableRenderOptions extends MemoryDisplayConfiguration { columnOptions: Array<{ label: string, doRender: boolean }>; endianness: Endianness; - wordsPerGroup: number; - groupsPerRow: number; wordSize: number; } @@ -73,9 +72,17 @@ export interface FullNodeAttributes extends StylableNodeAttributes { content: string; } -export interface MemoryInspectorConfiguration { +export interface MemoryDisplayConfiguration { wordsPerGroup: number; groupsPerRow: number; - showVariablesColumn: boolean; - showAsciiColumn: boolean; +} + +export interface ColumnVisibilityStatus { + id: string; + active: boolean; +} + +export interface MemoryDisplayConfigurationChangeRequest { + id: keyof MemoryDisplayConfiguration; + value: number; } From 30d8d644af64011b771b574539e33273deec70b3 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Tue, 5 Sep 2023 16:18:51 -0500 Subject: [PATCH 03/12] fix lint --- src/webview/utils/view-types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/webview/utils/view-types.ts b/src/webview/utils/view-types.ts index 3097841..472edb1 100644 --- a/src/webview/utils/view-types.ts +++ b/src/webview/utils/view-types.ts @@ -18,7 +18,6 @@ import type { DebugProtocol } from '@vscode/debugprotocol'; import type * as React from 'react'; import { areRangesEqual, BigIntMemoryRange } from '../../common/memory-range'; import deepequal from 'fast-deep-equal'; -import { TableRenderOptions } from '../columns/column-contribution-service'; export enum Endianness { Little = 'Little Endian', From dcf7d774a3096448eac655f30c55ea3e3c4fab94 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Wed, 6 Sep 2023 14:57:57 -0500 Subject: [PATCH 04/12] handle panel hide/show and send prefs onReady --- src/common/messaging.ts | 2 -- src/plugin/memory-webview-main.ts | 38 ++++++++++++------------ src/webview/components/memory-widget.tsx | 6 +--- src/webview/memory-webview-view.tsx | 5 ---- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/common/messaging.ts b/src/common/messaging.ts index 0abadd4..ab03792 100644 --- a/src/common/messaging.ts +++ b/src/common/messaging.ts @@ -24,10 +24,8 @@ export type MemoryWriteResult = DebugProtocol.WriteMemoryResponse['body']; export const readyType: NotificationType = { method: 'ready' }; export const logMessageType: RequestType = { method: 'logMessage' }; -export const getMemoryDisplayConfigurationType: RequestType = { method: 'getMemoryDisplayConfiguration' }; export const setMemoryDisplayConfigurationType: NotificationType = { method: 'setMemoryDisplayConfiguration' }; export const memoryDisplayConfigurationChangedType: NotificationType = { method: 'memoryDisplayConfigurationChanged' }; -export const getColumnsVisibility: RequestType = { method: 'getColumnsVisibility' }; export const columnVisibilityType: NotificationType = { method: 'columnVisibility' }; export const setOptionsType: RequestType, void> = { method: 'setOptions' }; export const readMemoryType: RequestType = { method: 'readMemory' }; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index 9805836..509c717 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -31,8 +31,6 @@ import { memoryDisplayConfigurationChangedType, columnVisibilityType, setMemoryDisplayConfigurationType, - getColumnsVisibility, - getMemoryDisplayConfigurationType, } from '../common/messaging'; import { MemoryProvider } from './memory-provider'; import { outputChannelLogger } from './logger'; @@ -52,6 +50,10 @@ enum RefreshEnum { } const isMemoryVariable = (variable: Variable): variable is Variable => variable && !!(variable as Variable).memoryReference; +const columnConfigurations = [ + manifest.CONFIG_SHOW_ASCII_COLUMN, + manifest.CONFIG_SHOW_VARIABLES_COLUMN, +]; export class MemoryWebview { public static ViewType = `${manifest.PACKAGE_NAME}.memory`; @@ -142,13 +144,13 @@ export class MemoryWebview { const participant = this.messenger.registerWebviewPanel(panel); const disposables = [ - this.messenger.onNotification(readyType, () => this.refresh(participant, options), { sender: participant }), + this.messenger.onNotification(readyType, () => { + this.refresh(participant, options); + }, { sender: participant }), this.messenger.onRequest(logMessageType, message => outputChannelLogger.info('[webview]:', message), { sender: participant }), this.messenger.onRequest(readMemoryType, request => this.readMemory(request), { sender: participant }), this.messenger.onRequest(writeMemoryType, request => this.writeMemory(request), { sender: participant }), this.messenger.onRequest(getVariables, request => this.getVariables(request), { sender: participant }), - this.messenger.onRequest(getMemoryDisplayConfigurationType, () => this.getMemoryDisplayConfiguration(), { sender: participant }), - this.messenger.onRequest(getColumnsVisibility, () => this.getColumnConfigurations(), { sender: participant }), this.messenger.onNotification(setMemoryDisplayConfigurationType, request => this.setConfiguration(request), { sender: participant }), this.messenger.onNotification(columnVisibilityType, request => this.handleColumnToggled(request), { sender: participant }), @@ -160,7 +162,11 @@ export class MemoryWebview { this.onMemoryDisplayConfigurationChanged(participant), this.onColumnVisibilityConfigurationChanged(participant), ]; - + panel.onDidChangeViewState(newState => { + if (newState.webviewPanel.visible) { + this.refresh(participant, options); + } + }); panel.onDidDispose(() => disposables.forEach(disposible => disposible.dispose())); } @@ -176,6 +182,13 @@ export class MemoryWebview { protected async refresh(participant: WebviewIdMessageParticipant, options?: Partial): Promise { this.messenger.sendRequest(setOptionsType, participant, options); + const memoryDisplayConfiguration = this.getMemoryDisplayConfiguration(); + this.messenger.sendNotification(memoryDisplayConfigurationChangedType, participant, memoryDisplayConfiguration); + columnConfigurations.forEach(columnConfiguration => { + const [id] = columnConfiguration.split('Visible'); + const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(columnConfiguration) ?? true; + this.messenger.sendNotification(columnVisibilityType, participant, { id, active }); + }); } protected getMemoryDisplayConfiguration(): MemoryDisplayConfiguration { @@ -199,10 +212,6 @@ export class MemoryWebview { } protected onColumnVisibilityConfigurationChanged(participant: MessageParticipant): vscode.Disposable { - const columnConfigurations = [ - manifest.CONFIG_SHOW_ASCII_COLUMN, - manifest.CONFIG_SHOW_VARIABLES_COLUMN, - ]; return vscode.workspace.onDidChangeConfiguration(e => { columnConfigurations.forEach(configuration => { if (e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configuration}`)) { @@ -214,15 +223,6 @@ export class MemoryWebview { }); } - protected getColumnConfigurations(): ColumnVisibilityStatus[] { - const COLUMN_CONFIGURATIONS = [manifest.CONFIG_SHOW_VARIABLES_COLUMN, manifest.CONFIG_SHOW_ASCII_COLUMN]; - return COLUMN_CONFIGURATIONS.map(configuration => { - const [id] = configuration.split('Visible'); - const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(configuration) ?? false; - return { id, active }; - }); - } - protected async readMemory(request: DebugProtocol.ReadMemoryArguments): Promise { try { return await this.memoryProvider.readMemory(request); diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index fee257e..3dd7089 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -20,8 +20,7 @@ import { MemoryTable } from './memory-table'; import { OptionsWidget } from './options-widget'; import { Decoration, Endianness, Memory, MemoryDisplayConfiguration } from '../utils/view-types'; import { messenger } from '../view-messenger'; -import { getMemoryDisplayConfigurationType, memoryDisplayConfigurationChangedType } from '../../common/messaging'; -import { HOST_EXTENSION } from 'vscode-messenger-common'; +import { memoryDisplayConfigurationChangedType } from '../../common/messaging'; import { ColumnStatus } from '../columns/column-contribution-service'; interface MemoryWidgetProps { @@ -56,9 +55,6 @@ export class MemoryWidget extends React.Component this.setState(configuration)); - messenger.sendRequest(getMemoryDisplayConfigurationType, HOST_EXTENSION, undefined).then(configuration => { - this.setState(configuration); - }); } override render(): React.ReactNode { diff --git a/src/webview/memory-webview-view.tsx b/src/webview/memory-webview-view.tsx index af5aa51..c627f29 100644 --- a/src/webview/memory-webview-view.tsx +++ b/src/webview/memory-webview-view.tsx @@ -23,7 +23,6 @@ import { setOptionsType, readMemoryType, columnVisibilityType, - getColumnsVisibility } from '../common/messaging'; import type { DebugProtocol } from '@vscode/debugprotocol'; import { ColumnVisibilityStatus, Decoration, Memory, MemoryState } from './utils/view-types'; @@ -67,10 +66,6 @@ class App extends React.Component<{}, MemoryAppState> { messenger.onRequest(setOptionsType, options => this.setOptions(options)); messenger.sendNotification(readyType, HOST_EXTENSION, undefined); messenger.onNotification(columnVisibilityType, request => this.handleColumnVisibilityChanged(request)); - messenger.sendRequest(getColumnsVisibility, HOST_EXTENSION, undefined).then(columnsVisibility => { - columnsVisibility.forEach(columnVisibility => this.handleColumnVisibilityChanged(columnVisibility)); - }); - } public render(): React.ReactNode { From 207fe2428fd3841e3c90c36089d806e96e1bec72 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Wed, 6 Sep 2023 16:40:22 -0500 Subject: [PATCH 05/12] add preference for more memory behavior --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.json b/package.json index 6afc5c0..47bea37 100644 --- a/package.json +++ b/package.json @@ -172,6 +172,15 @@ "type": "boolean", "default": false, "description": "Show ASCII column?" + }, + "memory-inspector.scrollingBehavior": { + "type": "string", + "enum": [ + "Infinite", + "Paginate" + ], + "default": "Paginate", + "description": "Behavior when adding more data beyond the current view. 'Infinite' appends new memory to bounds of current request, resulting in a growing list. 'Paginate' maintains a consistent memory size, replacing the previous request." } } } From b8838a3a2ee78a0472f33ddc7f1568ac4dd90f56 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Wed, 6 Sep 2023 16:52:39 -0500 Subject: [PATCH 06/12] propagate scrollingBehavior to component --- src/plugin/manifest.ts | 3 +++ src/plugin/memory-webview-main.ts | 6 ++++-- src/webview/components/memory-table.tsx | 9 ++++++--- src/webview/components/memory-widget.tsx | 4 +++- src/webview/components/options-widget.tsx | 2 +- src/webview/utils/view-types.ts | 2 ++ 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugin/manifest.ts b/src/plugin/manifest.ts index a95d20a..9e5dd14 100644 --- a/src/plugin/manifest.ts +++ b/src/plugin/manifest.ts @@ -27,5 +27,8 @@ export const CONFIG_WORDS_PER_GROUP = 'wordsPerGroup'; export const DEFAULT_WORDS_PER_GROUP = 1; export const CONFIG_GROUPS_PER_ROW = 'groupsPerRow'; export const DEFAULT_GROUPS_PER_ROW = 4; +export const CONFIG_SCROLLING_BEHAVIOR = 'scrollingBehavior'; +export const DEFAULT_SCROLLING_BEHAVIOR = 'Paginate'; + export const CONFIG_SHOW_VARIABLES_COLUMN = 'variablesVisible'; export const CONFIG_SHOW_ASCII_COLUMN = 'asciiVisible'; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index d4222ec..b3e7894 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -35,7 +35,7 @@ import { import { MemoryProvider } from './memory-provider'; import { outputChannelLogger } from './logger'; import { VariableRange } from '../common/memory-range'; -import { ColumnVisibilityStatus, MemoryDisplayConfiguration as MemoryDisplayConfiguration } from '../webview/utils/view-types'; +import { ColumnVisibilityStatus, MemoryDisplayConfiguration as MemoryDisplayConfiguration, ScrollingBehavior } from '../webview/utils/view-types'; interface Variable { name: string; @@ -197,13 +197,15 @@ export class MemoryWebview { const memoryInspectorConfiguration = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME); const wordsPerGroup = memoryInspectorConfiguration.get(manifest.CONFIG_WORDS_PER_GROUP) || manifest.DEFAULT_WORDS_PER_GROUP; const groupsPerRow = memoryInspectorConfiguration.get(manifest.CONFIG_GROUPS_PER_ROW) || manifest.DEFAULT_GROUPS_PER_ROW; - return { wordsPerGroup, groupsPerRow }; + const scrollingBehavior = memoryInspectorConfiguration.get(manifest.CONFIG_SCROLLING_BEHAVIOR) || manifest.DEFAULT_SCROLLING_BEHAVIOR; + return { wordsPerGroup, groupsPerRow, scrollingBehavior }; } protected onMemoryDisplayConfigurationChanged(participant: MessageParticipant): vscode.Disposable { const memoryDisplayConfigurations = [ manifest.CONFIG_WORDS_PER_GROUP, manifest.CONFIG_GROUPS_PER_ROW, + manifest.CONFIG_SCROLLING_BEHAVIOR, ]; return vscode.workspace.onDidChangeConfiguration(e => { if (memoryDisplayConfigurations.some(configurationOption => e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configurationOption}`))) { diff --git a/src/webview/components/memory-table.tsx b/src/webview/components/memory-table.tsx index 50586bb..0c9c038 100644 --- a/src/webview/components/memory-table.tsx +++ b/src/webview/components/memory-table.tsx @@ -20,7 +20,7 @@ import { VSCodeDataGridRow, VSCodeDataGridCell } from '@vscode/webview-ui-toolkit/react'; -import { Decoration, Memory, MemoryDisplayConfiguration, StylableNodeAttributes, isTrigger } from '../utils/view-types'; +import { Decoration, Memory, MemoryDisplayConfiguration, ScrollingBehavior, StylableNodeAttributes, isTrigger } from '../utils/view-types'; import { toHexStringWithRadixMarker } from '../../common/memory-range'; import { TableRenderOptions } from '../columns/column-contribution-service'; import { DebugProtocol } from '@vscode/debugprotocol'; @@ -30,10 +30,11 @@ export interface MoreMemorySelectProps { offset: number; options: number[]; direction: 'above' | 'below'; + scrollingBehavior: ScrollingBehavior; fetchMemory(partialOptions?: Partial): Promise; } -export const MoreMemorySelect: React.FC = ({ count, offset, options, fetchMemory, direction }) => { +export const MoreMemorySelect: React.FC = ({ count, offset, options, fetchMemory, direction, scrollingBehavior }) => { const [numBytes, setNumBytes] = React.useState(options[0]); const containerRef = React.createRef(); const onSelectChange = (e: React.ChangeEvent): void => { @@ -96,7 +97,7 @@ interface MemoryTableProps extends TableRenderOptions, MemoryDisplayConfiguratio export class MemoryTable extends React.Component { public render(): React.ReactNode { const rows = this.getTableRows(); - const { offset, count, memory, fetchMemory } = this.props; + const { offset, count, memory, fetchMemory, scrollingBehavior } = this.props; const showMoreMemoryButton = !!memory?.bytes.length; return (
@@ -115,6 +116,7 @@ export class MemoryTable extends React.Component { count={count} options={[128, 256, 512]} direction='above' + scrollingBehavior={scrollingBehavior} fetchMemory={fetchMemory} />)} {rows} @@ -123,6 +125,7 @@ export class MemoryTable extends React.Component { count={count} options={[128, 256, 512]} direction='below' + scrollingBehavior={scrollingBehavior} fetchMemory={fetchMemory} />)} diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index 5896c46..62ab190 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -18,7 +18,7 @@ import { DebugProtocol } from '@vscode/debugprotocol'; import React from 'react'; import { MemoryTable } from './memory-table'; import { OptionsWidget } from './options-widget'; -import { Decoration, Endianness, Memory, MemoryDisplayConfiguration } from '../utils/view-types'; +import { Decoration, Endianness, Memory, MemoryDisplayConfiguration, ScrollingBehavior } from '../utils/view-types'; import { messenger } from '../view-messenger'; import { memoryDisplayConfigurationChangedType } from '../../common/messaging'; import { ColumnStatus } from '../columns/column-contribution-service'; @@ -46,6 +46,7 @@ const defaultOptions: MemoryWidgetState = { wordSize: 8, wordsPerGroup: 1, groupsPerRow: 4, + scrollingBehavior: 'Paginate', }; export class MemoryWidget extends React.Component { @@ -85,6 +86,7 @@ export class MemoryWidget extends React.Component ; } diff --git a/src/webview/components/options-widget.tsx b/src/webview/components/options-widget.tsx index a6ec935..30652eb 100644 --- a/src/webview/components/options-widget.tsx +++ b/src/webview/components/options-widget.tsx @@ -24,7 +24,7 @@ import { setMemoryDisplayConfigurationType } from '../../common/messaging'; import { HOST_EXTENSION } from 'vscode-messenger-common'; import { TableRenderOptions } from '../columns/column-contribution-service'; -export interface OptionsWidgetProps extends TableRenderOptions, Required, MemoryDisplayConfiguration { +export interface OptionsWidgetProps extends Omit, Required { updateRenderOptions: (options: Partial) => void; updateMemoryArguments: (memoryArguments: Partial) => void; refreshMemory: () => void; diff --git a/src/webview/utils/view-types.ts b/src/webview/utils/view-types.ts index ac10185..0fc5b12 100644 --- a/src/webview/utils/view-types.ts +++ b/src/webview/utils/view-types.ts @@ -71,9 +71,11 @@ export interface FullNodeAttributes extends StylableNodeAttributes { content: string; } +export type ScrollingBehavior = 'Paginate' | 'Infinite'; export interface MemoryDisplayConfiguration { wordsPerGroup: number; groupsPerRow: number; + scrollingBehavior: ScrollingBehavior; } export interface ColumnVisibilityStatus { From 5c406d39904ec1fffa9c33a8b4a937725911db44 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Wed, 6 Sep 2023 17:05:22 -0500 Subject: [PATCH 07/12] implmement scrolling behaviors --- package.json | 4 ++-- src/webview/components/memory-table.tsx | 8 +++++++- src/webview/components/memory-widget.tsx | 2 +- src/webview/components/options-widget.tsx | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 47bea37..449ec7b 100644 --- a/package.json +++ b/package.json @@ -176,8 +176,8 @@ "memory-inspector.scrollingBehavior": { "type": "string", "enum": [ - "Infinite", - "Paginate" + "Paginate", + "Infinite" ], "default": "Paginate", "description": "Behavior when adding more data beyond the current view. 'Infinite' appends new memory to bounds of current request, resulting in a growing list. 'Paginate' maintains a consistent memory size, replacing the previous request." diff --git a/src/webview/components/memory-table.tsx b/src/webview/components/memory-table.tsx index 0c9c038..1bb587a 100644 --- a/src/webview/components/memory-table.tsx +++ b/src/webview/components/memory-table.tsx @@ -51,7 +51,13 @@ export const MoreMemorySelect: React.FC = ({ count, offse if (direction === 'above') { newOffset = offset - numBytes; } - newCount = count + numBytes; + if (scrollingBehavior === 'Infinite') { + newCount = count + numBytes; + } else { + if (direction === 'below') { + newOffset = offset + numBytes; + } + } fetchMemory({ offset: newOffset, count: newCount }); } }; diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index 62ab190..2e68a16 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -18,7 +18,7 @@ import { DebugProtocol } from '@vscode/debugprotocol'; import React from 'react'; import { MemoryTable } from './memory-table'; import { OptionsWidget } from './options-widget'; -import { Decoration, Endianness, Memory, MemoryDisplayConfiguration, ScrollingBehavior } from '../utils/view-types'; +import { Decoration, Endianness, Memory, MemoryDisplayConfiguration } from '../utils/view-types'; import { messenger } from '../view-messenger'; import { memoryDisplayConfigurationChangedType } from '../../common/messaging'; import { ColumnStatus } from '../columns/column-contribution-service'; diff --git a/src/webview/components/options-widget.tsx b/src/webview/components/options-widget.tsx index 30652eb..32bd370 100644 --- a/src/webview/components/options-widget.tsx +++ b/src/webview/components/options-widget.tsx @@ -16,7 +16,7 @@ import React from 'react'; import type { DebugProtocol } from '@vscode/debugprotocol'; -import { MemoryDisplayConfiguration, MemoryDisplayConfigurationChangeRequest, SerializedTableRenderOptions } from '../utils/view-types'; +import { MemoryDisplayConfigurationChangeRequest, SerializedTableRenderOptions } from '../utils/view-types'; import { VSCodeButton, VSCodeDivider, VSCodeDropdown, VSCodeOption, VSCodeTextField } from '@vscode/webview-ui-toolkit/react'; import { MultiSelectWithLabel } from './multi-select-bar'; import { messenger } from '../view-messenger'; From 51000b9301e3c8db93c6383f650f710f8b91e641 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Wed, 6 Sep 2023 17:08:01 -0500 Subject: [PATCH 08/12] small description change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 449ec7b..568b729 100644 --- a/package.json +++ b/package.json @@ -180,7 +180,7 @@ "Infinite" ], "default": "Paginate", - "description": "Behavior when adding more data beyond the current view. 'Infinite' appends new memory to bounds of current request, resulting in a growing list. 'Paginate' maintains a consistent memory size, replacing the previous request." + "description": "Behavior when adding more memory beyond the current view. 'Infinite' appends new memory to bounds of current request, resulting in a growing list. 'Paginate' maintains a consistent memory size, replacing the previous request." } } } From ec7c62544ee34fca14d266266721133cd0765965 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Tue, 19 Sep 2023 12:16:31 -0500 Subject: [PATCH 09/12] cleanup --- src/webview/components/options-widget.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webview/components/options-widget.tsx b/src/webview/components/options-widget.tsx index f27e15a..8297dc0 100644 --- a/src/webview/components/options-widget.tsx +++ b/src/webview/components/options-widget.tsx @@ -39,7 +39,7 @@ const enum InputId { Address = 'address', Offset = 'offset', Length = 'length', - wordsPerGroup = 'bytes-per-group', + WordsPerGroup = 'words-per-group', GroupsPerRow = 'groups-per-row', } @@ -68,8 +68,8 @@ export class OptionsWidget extends React.Component
- - + + 1 2 4 @@ -109,7 +109,7 @@ export class OptionsWidget extends React.Component Date: Tue, 19 Sep 2023 12:29:59 -0500 Subject: [PATCH 10/12] address CJ feedback --- package.json | 16 ++++++++++++---- src/plugin/manifest.ts | 4 ++-- src/plugin/memory-webview-main.ts | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 568b729..f399e80 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,11 @@ "items": { "type": "string" }, - "default": [ "gdb", "embedded-debug", "arm-debug" ], + "default": [ + "gdb", + "embedded-debug", + "arm-debug" + ], "description": "C-based debuggers to activate (requires debug session restart)" }, "memory-inspector.refreshOnStop": { @@ -163,12 +167,12 @@ "default": 4, "description": "Default groups per row" }, - "memory-inspector.variablesVisible": { + "memory-inspector.columns.variables": { "type": "boolean", "default": false, "description": "Show variables column?" }, - "memory-inspector.asciiVisible": { + "memory-inspector.columns.ascii": { "type": "boolean", "default": false, "description": "Show ASCII column?" @@ -180,7 +184,11 @@ "Infinite" ], "default": "Paginate", - "description": "Behavior when adding more memory beyond the current view. 'Infinite' appends new memory to bounds of current request, resulting in a growing list. 'Paginate' maintains a consistent memory size, replacing the previous request." + "enumDescriptions": [ + "Maintains a consistent memory size, replacing the previous request.", + "Appends new memory to bounds of current request, resulting in a growing list." + ], + "description": "Behavior when adding more memory beyond the current view." } } } diff --git a/src/plugin/manifest.ts b/src/plugin/manifest.ts index 9e5dd14..e1d5490 100644 --- a/src/plugin/manifest.ts +++ b/src/plugin/manifest.ts @@ -30,5 +30,5 @@ export const DEFAULT_GROUPS_PER_ROW = 4; export const CONFIG_SCROLLING_BEHAVIOR = 'scrollingBehavior'; export const DEFAULT_SCROLLING_BEHAVIOR = 'Paginate'; -export const CONFIG_SHOW_VARIABLES_COLUMN = 'variablesVisible'; -export const CONFIG_SHOW_ASCII_COLUMN = 'asciiVisible'; +export const CONFIG_SHOW_VARIABLES_COLUMN = 'columns.variables'; +export const CONFIG_SHOW_ASCII_COLUMN = 'columns.ascii'; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index b3e7894..d1c62f7 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -187,7 +187,7 @@ export class MemoryWebview { const memoryDisplayConfiguration = this.getMemoryDisplayConfiguration(); this.messenger.sendNotification(memoryDisplayConfigurationChangedType, participant, memoryDisplayConfiguration); columnConfigurations.forEach(columnConfiguration => { - const [id] = columnConfiguration.split('Visible'); + const [, id] = columnConfiguration.split('.'); const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(columnConfiguration) ?? true; this.messenger.sendNotification(columnVisibilityType, participant, { id, active }); }); @@ -219,7 +219,7 @@ export class MemoryWebview { return vscode.workspace.onDidChangeConfiguration(e => { columnConfigurations.forEach(configuration => { if (e.affectsConfiguration(`${manifest.PACKAGE_NAME}.${configuration}`)) { - const [id] = configuration.split('Visible'); + const [, id] = configuration.split('.'); const active = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get(configuration) ?? true; this.messenger.sendNotification(columnVisibilityType, participant, { id, active }); } From af6850065367f7132dbf417d837b7da6d3d2bcc7 Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Tue, 19 Sep 2023 12:38:33 -0500 Subject: [PATCH 11/12] missed one reference --- src/plugin/memory-webview-main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index d1c62f7..15d5c6d 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -174,7 +174,7 @@ export class MemoryWebview { protected handleColumnToggled(request: ColumnVisibilityStatus): void { const { id, active: visible } = request; - vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).update(`${id}Visible`, visible, vscode.ConfigurationTarget.Global); + vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).update(`columns.${id}`, visible, vscode.ConfigurationTarget.Global); } protected setConfiguration(request: { id: string, value: unknown }): void { From ec970a7becb75617abd62ae895c91ae3be7ca20b Mon Sep 17 00:00:00 2001 From: eeakrnm Date: Tue, 19 Sep 2023 12:50:21 -0500 Subject: [PATCH 12/12] add category for groupings --- package.json | 4 ++-- src/plugin/manifest.ts | 4 ++-- src/webview/components/options-widget.tsx | 4 ++-- src/webview/utils/view-types.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index f399e80..3113717 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "default": "on", "description": "Refresh memory views when debugger stops" }, - "memory-inspector.wordsPerGroup": { + "memory-inspector.groupings.wordsPerGroup": { "type": "number", "enum": [ 1, @@ -154,7 +154,7 @@ "default": 1, "description": "Default words per group" }, - "memory-inspector.groupsPerRow": { + "memory-inspector.groupings.groupsPerRow": { "type": "number", "enum": [ 1, diff --git a/src/plugin/manifest.ts b/src/plugin/manifest.ts index e1d5490..1edbce2 100644 --- a/src/plugin/manifest.ts +++ b/src/plugin/manifest.ts @@ -23,9 +23,9 @@ export const DEFAULT_DEBUG_TYPES = [ 'gdb', 'embedded-debug', 'arm-debug' ]; export const CONFIG_REFRESH_ON_STOP = 'refreshOnStop'; export const DEFAULT_REFRESH_ON_STOP = 'on'; -export const CONFIG_WORDS_PER_GROUP = 'wordsPerGroup'; +export const CONFIG_WORDS_PER_GROUP = 'groupings.wordsPerGroup'; export const DEFAULT_WORDS_PER_GROUP = 1; -export const CONFIG_GROUPS_PER_ROW = 'groupsPerRow'; +export const CONFIG_GROUPS_PER_ROW = 'groupings.groupsPerRow'; export const DEFAULT_GROUPS_PER_ROW = 4; export const CONFIG_SCROLLING_BEHAVIOR = 'scrollingBehavior'; export const DEFAULT_SCROLLING_BEHAVIOR = 'Paginate'; diff --git a/src/webview/components/options-widget.tsx b/src/webview/components/options-widget.tsx index 8297dc0..5ff6497 100644 --- a/src/webview/components/options-widget.tsx +++ b/src/webview/components/options-widget.tsx @@ -109,8 +109,8 @@ export class OptionsWidget extends React.Component