diff --git a/package.json b/package.json index c0f5e71..f7e3609 100644 --- a/package.json +++ b/package.json @@ -310,7 +310,7 @@ "type": "number", "default": 500, "minimum": 500, - "markdownDescription": "Controls the delay in milliseconds after which a Memory Inspector is refrehsed automatically. Only applies when `#memory-inspector.periodicRefresh#` is enabled." + "markdownDescription": "Controls the delay in milliseconds after which a Memory Inspector is refreshed automatically. Only applies when `#memory-inspector.periodicRefresh#` is enabled." }, "memory-inspector.groupings.bytesPerMAU": { "type": "number", diff --git a/src/plugin/external-views.ts b/src/common/external-views.ts similarity index 100% rename from src/plugin/external-views.ts rename to src/common/external-views.ts diff --git a/src/common/messaging.ts b/src/common/messaging.ts index 480557c..fb5954d 100644 --- a/src/common/messaging.ts +++ b/src/common/messaging.ts @@ -17,8 +17,8 @@ import type { DebugProtocol } from '@vscode/debugprotocol'; import type { NotificationType, RequestType } from 'vscode-messenger-common'; import { URI } from 'vscode-uri'; -import { VariablesView } from '../plugin/external-views'; import { DebugRequestTypes } from './debug-requests'; +import { VariablesView } from './external-views'; import type { VariableRange, WrittenMemory } from './memory-range'; import { MemoryViewSettings } from './webview-configuration'; import { WebviewContext } from './webview-context'; diff --git a/src/common/webview-context.ts b/src/common/webview-context.ts index 13f9076..ac142f2 100644 --- a/src/common/webview-context.ts +++ b/src/common/webview-context.ts @@ -16,6 +16,7 @@ import { WebviewIdMessageParticipant } from 'vscode-messenger-common'; import * as manifest from '../common/manifest'; +import { Endianness } from './manifest'; import { VariableMetadata } from './memory-range'; import { ReadMemoryArguments } from './messaging'; @@ -26,6 +27,8 @@ export interface WebviewContext { showVariablesColumn: boolean, showRadixPrefix: boolean, hasDebuggerDefaults?: boolean, + endianness: Endianness, + bytesPerMau: number, activeReadArguments: Required } diff --git a/src/plugin/memory-storage.ts b/src/plugin/memory-storage.ts index 8604036..a19036b 100644 --- a/src/plugin/memory-storage.ts +++ b/src/plugin/memory-storage.ts @@ -17,6 +17,7 @@ import MemoryMap from 'nrf-intel-hex'; import * as vscode from 'vscode'; import { URI, Utils } from 'vscode-uri'; +import { isVariablesContext } from '../common/external-views'; import { IntelHEX } from '../common/intel-hex'; import * as manifest from '../common/manifest'; import { @@ -26,7 +27,6 @@ import { import { toHexStringWithRadixMarker } from '../common/memory-range'; import { ApplyMemoryArguments, ApplyMemoryResult, MemoryOptions, StoreMemoryArguments } from '../common/messaging'; import { isWebviewContext } from '../common/webview-context'; -import { isVariablesContext } from './external-views'; import { MemoryProvider } from './memory-provider'; export const StoreCommandType = `${manifest.PACKAGE_NAME}.store-file`; diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index 2b11b72..d13914a 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -17,6 +17,7 @@ import * as vscode from 'vscode'; import { Messenger } from 'vscode-messenger'; import { WebviewIdMessageParticipant } from 'vscode-messenger-common'; +import { isVariablesContext } from '../common/external-views'; import * as manifest from '../common/manifest'; import { VariableRange } from '../common/memory-range'; import { @@ -46,7 +47,6 @@ import { import { MemoryDisplaySettings, MemoryDisplaySettingsContribution, MemoryViewSettings, ScrollingBehavior } from '../common/webview-configuration'; import { getVisibleColumns, isWebviewVariableContext, WebviewContext } from '../common/webview-context'; import { AddressPaddingOptions } from '../webview/utils/view-types'; -import { isVariablesContext } from './external-views'; import { outputChannelLogger } from './logger'; import { MemoryProvider } from './memory-provider'; import { ApplyCommandType, StoreCommandType } from './memory-storage'; @@ -296,8 +296,8 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider { const sessionId = session?.id; return { sessionId, - canRead: !!this.sessionTracker.hasDebugCapabilitiy(session, 'supportsReadMemoryRequest'), - canWrite: !!this.sessionTracker.hasDebugCapabilitiy(session, 'supportsWriteMemoryRequest'), + canRead: !!this.sessionTracker.hasDebugCapability(session, 'supportsReadMemoryRequest'), + canWrite: !!this.sessionTracker.hasDebugCapability(session, 'supportsWriteMemoryRequest'), stopped: this.sessionTracker.isStopped(session) }; } diff --git a/src/plugin/session-tracker.ts b/src/plugin/session-tracker.ts index 3ca95b4..d10529f 100644 --- a/src/plugin/session-tracker.ts +++ b/src/plugin/session-tracker.ts @@ -158,23 +158,23 @@ export class SessionTracker implements vscode.DebugAdapterTrackerFactory { return !!session && !!this.sessionInfo(session).stopped; } - hasDebugCapabilitiy(session = this.activeSession, capability: DebugCapability): boolean { + hasDebugCapability(session = this.activeSession, capability: DebugCapability): boolean { return !!session && !!this.sessionInfo(session).debugCapabilities?.[capability]; } assertDebugCapability(session = this.assertActiveSession(), capability: DebugCapability, action: string = 'execute action'): vscode.DebugSession { - if (!this.hasDebugCapabilitiy(session, capability)) { + if (!this.hasDebugCapability(session, capability)) { throw new Error(`Cannot ${action}. Session does not have capability '${capability}'.`); } return session; } - hasClientCapabilitiy(session: vscode.DebugSession | undefined, capability: ClientCapability): boolean { + hasClientCapability(session: vscode.DebugSession | undefined, capability: ClientCapability): boolean { return !!session && !!this.sessionInfo(session).clientCapabilities?.[capability]; } assertClientCapability(session = this.assertActiveSession(), capability: ClientCapability, action: string = 'execute action'): vscode.DebugSession { - if (!this.hasClientCapabilitiy(session, capability)) { + if (!this.hasClientCapability(session, capability)) { throw new Error(`Cannot ${action}. Client does not have capability '${capability}'.`); } return session; diff --git a/src/webview/columns/data-column.tsx b/src/webview/columns/data-column.tsx index c6a8b59..4a929c2 100644 --- a/src/webview/columns/data-column.tsx +++ b/src/webview/columns/data-column.tsx @@ -23,6 +23,7 @@ import { writeMemoryType } from '../../common/messaging'; import type { MemorySizeOptions } from '../components/memory-table'; import { decorationService } from '../decorations/decoration-service'; import { Disposable, FullNodeAttributes } from '../utils/view-types'; +import { createGroupVscodeContext } from '../utils/vscode-contexts'; import { characterWidthInContainer, elementInnerWidth } from '../utils/window'; import { messenger } from '../view-messenger'; import { ColumnContribution, TableRenderOptions } from './column-contribution-service'; @@ -87,6 +88,7 @@ export class EditableDataColumnRow extends React.Component {maus} ; diff --git a/src/webview/components/memory-widget.tsx b/src/webview/components/memory-widget.tsx index 73a7218..1c46fbf 100644 --- a/src/webview/components/memory-widget.tsx +++ b/src/webview/components/memory-widget.tsx @@ -69,13 +69,16 @@ export class MemoryWidget extends React.Component candidate.active).map(column => column.contribution.id); + const { messageParticipant, showRadixPrefix, endianness, bytesPerMau, activeReadArguments, hasDebuggerDefaults } = this.props; return createAppVscodeContext({ - messageParticipant: this.props.messageParticipant, - showRadixPrefix: this.props.showRadixPrefix, + messageParticipant, + showRadixPrefix, showAsciiColumn: visibleColumns.includes(manifest.CONFIG_SHOW_ASCII_COLUMN), showVariablesColumn: visibleColumns.includes(manifest.CONFIG_SHOW_VARIABLES_COLUMN), - activeReadArguments: this.props.activeReadArguments, - hasDebuggerDefaults: this.props.hasDebuggerDefaults, + activeReadArguments, + hasDebuggerDefaults, + endianness, + bytesPerMau, }); } diff --git a/src/webview/utils/vscode-contexts.ts b/src/webview/utils/vscode-contexts.ts index 6ddb510..9ea3206 100644 --- a/src/webview/utils/vscode-contexts.ts +++ b/src/webview/utils/vscode-contexts.ts @@ -28,7 +28,7 @@ export interface VscodeContext { export type WebviewSection = 'optionsWidget' | 'advancedOptionsOverlay' | 'memoryTable'; export function createVscodeContext(context: C): VscodeContext { - return { 'data-vscode-context': JSON.stringify(includeFlatKeys(context)) }; + return { 'data-vscode-context': JSON.stringify(includeFlatKeys(context), replacerForBigInt) }; } function includeFlatKeys(src: object): Record { @@ -64,8 +64,19 @@ export function createAppVscodeContext(context: Omit