Skip to content

Commit

Permalink
Merge branch 'main' into session-support
Browse files Browse the repository at this point in the history
  • Loading branch information
thegecko committed Jan 9, 2025
2 parents bd02d8d + 915701a commit 1d796f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/plugin/memory-webview-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
}

// Set HTML content
await this.getWebviewContent(panel);
await this.getWebviewContent(panel, initialMemory);

// Sets up an event listener to listen for messages passed from the webview view context
// and executes code based on the message that is received
this.setWebviewMessageListener(panel, initialMemory);
}

protected async getWebviewContent(panel: vscode.WebviewPanel): Promise<void> {
protected async getWebviewContent(panel: vscode.WebviewPanel, initialMemory?: MemoryOptions): Promise<void> {
const mainUri = panel.webview.asWebviewUri(vscode.Uri.joinPath(
this.extensionUri,
'dist',
Expand All @@ -205,7 +205,7 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
<link href="${memoryInspectorCSS}" rel="stylesheet" />
</head>
<body>
<div id='root'></div>
<div id='root'></div>${initialMemory ? `<div id='initial-data' data-options='${JSON.stringify(initialMemory)}'></div>` : ''}
</body>
</html>
`;
Expand Down Expand Up @@ -334,7 +334,6 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
this.setSession(participant, vscode.debug.activeDebugSession?.id);
this.setSessions(participant, this.sessionTracker.getSessions());
await this.setMemoryDisplaySettings(participant, panel.title);
this.refresh(participant, options);
}

protected async setSession(participant: WebviewIdMessageParticipant, sessionId: string | undefined): Promise<void> {
Expand Down
13 changes: 11 additions & 2 deletions src/webview/memory-webview-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,18 @@ export const DEFAULT_MEMORY_DISPLAY_CONFIGURATION: MemoryDisplaySettings = {
visibleColumns: manifest.DEFAULT_VISIBLE_COLUMNS
};

function getInitialValuesHolder(): HTMLElement | null {
return document.getElementById('initial-data');
}

class App extends React.Component<{}, MemoryAppState> {
protected memoryWidget = React.createRef<MemoryWidget>();
protected refreshTimer?: NodeJS.Timeout | number;

public constructor(props: {}) {
super(props);
const initialValuesHolder = getInitialValuesHolder();
const initialReadArguments = initialValuesHolder ? { ...DEFAULT_READ_ARGUMENTS, ...JSON.parse(initialValuesHolder.dataset['options']!) } : DEFAULT_READ_ARGUMENTS;
columnContributionService.register(new AddressColumn(), false);
columnContributionService.register(new DataColumn(), false);
columnContributionService.register(variableDecorator);
Expand All @@ -111,8 +117,8 @@ class App extends React.Component<{}, MemoryAppState> {
sessionContext: DEFAULT_SESSION_CONTEXT,
memory: undefined,
effectiveAddressLength: 0,
configuredReadArguments: DEFAULT_READ_ARGUMENTS,
activeReadArguments: DEFAULT_READ_ARGUMENTS,
configuredReadArguments: initialReadArguments,
activeReadArguments: initialReadArguments,
decorations: [],
hoverService: hoverService,
columns: columnContributionService.getColumns(),
Expand All @@ -123,6 +129,9 @@ class App extends React.Component<{}, MemoryAppState> {
}

public componentDidMount(): void {
if (getInitialValuesHolder()) {
this.fetchMemory(this.state.activeReadArguments);
}
messenger.onRequest(setOptionsType, options => this.setOptions(options));
messenger.onNotification(memoryWrittenType, writtenMemory => this.memoryWritten(writtenMemory));
messenger.onNotification(sessionsChangedType, sessions => this.sessionsChanged(sessions));
Expand Down

0 comments on commit 1d796f6

Please sign in to comment.