Skip to content

Commit 12f1da2

Browse files
authored
Fix: DisplayContextSelection read violation (#547) (#548)
1 parent c4068b7 commit 12f1da2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

media/editor/state.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ const acquireVsCodeApi: () => {
3535
export const vscode = acquireVsCodeApi?.();
3636

3737
export const setWebviewState = (key: string, value: unknown) => {
38-
vscode.setState?.({ ...vscode.getState(), [key]: value });
38+
vscode.setState?.({ ...(vscode.getState?.() ?? {}), [key]: value });
3939
};
4040

4141
export const getWebviewState = <T>(key: string, defaultValue: T): T => {
42-
return vscode.getState?.()[key] ?? defaultValue;
42+
return (vscode.getState?.() ?? {})[key] ?? defaultValue;
4343
};
4444

4545
type HandlerFn = (message: ToWebviewMessage) => Promise<FromWebviewMessage> | undefined;

0 commit comments

Comments
 (0)