Skip to content

Commit 1d796f6

Browse files
committed
Merge branch 'main' into session-support
2 parents bd02d8d + 915701a commit 1d796f6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/plugin/memory-webview-main.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
174174
}
175175

176176
// Set HTML content
177-
await this.getWebviewContent(panel);
177+
await this.getWebviewContent(panel, initialMemory);
178178

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

184-
protected async getWebviewContent(panel: vscode.WebviewPanel): Promise<void> {
184+
protected async getWebviewContent(panel: vscode.WebviewPanel, initialMemory?: MemoryOptions): Promise<void> {
185185
const mainUri = panel.webview.asWebviewUri(vscode.Uri.joinPath(
186186
this.extensionUri,
187187
'dist',
@@ -205,7 +205,7 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
205205
<link href="${memoryInspectorCSS}" rel="stylesheet" />
206206
</head>
207207
<body>
208-
<div id='root'></div>
208+
<div id='root'></div>${initialMemory ? `<div id='initial-data' data-options='${JSON.stringify(initialMemory)}'></div>` : ''}
209209
</body>
210210
</html>
211211
`;
@@ -334,7 +334,6 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
334334
this.setSession(participant, vscode.debug.activeDebugSession?.id);
335335
this.setSessions(participant, this.sessionTracker.getSessions());
336336
await this.setMemoryDisplaySettings(participant, panel.title);
337-
this.refresh(participant, options);
338337
}
339338

340339
protected async setSession(participant: WebviewIdMessageParticipant, sessionId: string | undefined): Promise<void> {

src/webview/memory-webview-view.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ export const DEFAULT_MEMORY_DISPLAY_CONFIGURATION: MemoryDisplaySettings = {
9090
visibleColumns: manifest.DEFAULT_VISIBLE_COLUMNS
9191
};
9292

93+
function getInitialValuesHolder(): HTMLElement | null {
94+
return document.getElementById('initial-data');
95+
}
96+
9397
class App extends React.Component<{}, MemoryAppState> {
9498
protected memoryWidget = React.createRef<MemoryWidget>();
9599
protected refreshTimer?: NodeJS.Timeout | number;
96100

97101
public constructor(props: {}) {
98102
super(props);
103+
const initialValuesHolder = getInitialValuesHolder();
104+
const initialReadArguments = initialValuesHolder ? { ...DEFAULT_READ_ARGUMENTS, ...JSON.parse(initialValuesHolder.dataset['options']!) } : DEFAULT_READ_ARGUMENTS;
99105
columnContributionService.register(new AddressColumn(), false);
100106
columnContributionService.register(new DataColumn(), false);
101107
columnContributionService.register(variableDecorator);
@@ -111,8 +117,8 @@ class App extends React.Component<{}, MemoryAppState> {
111117
sessionContext: DEFAULT_SESSION_CONTEXT,
112118
memory: undefined,
113119
effectiveAddressLength: 0,
114-
configuredReadArguments: DEFAULT_READ_ARGUMENTS,
115-
activeReadArguments: DEFAULT_READ_ARGUMENTS,
120+
configuredReadArguments: initialReadArguments,
121+
activeReadArguments: initialReadArguments,
116122
decorations: [],
117123
hoverService: hoverService,
118124
columns: columnContributionService.getColumns(),
@@ -123,6 +129,9 @@ class App extends React.Component<{}, MemoryAppState> {
123129
}
124130

125131
public componentDidMount(): void {
132+
if (getInitialValuesHolder()) {
133+
this.fetchMemory(this.state.activeReadArguments);
134+
}
126135
messenger.onRequest(setOptionsType, options => this.setOptions(options));
127136
messenger.onNotification(memoryWrittenType, writtenMemory => this.memoryWritten(writtenMemory));
128137
messenger.onNotification(sessionsChangedType, sessions => this.sessionsChanged(sessions));

0 commit comments

Comments
 (0)