Skip to content

Commit

Permalink
Fix: DisplayContextSelection read violation (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa3333 committed Nov 2, 2024
1 parent 9aefbec commit 0edb602
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions media/editor/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const acquireVsCodeApi: () => {
export const vscode = acquireVsCodeApi?.();

export const setWebviewState = (key: string, value: unknown) => {
vscode.setState?.({ ...vscode.getState(), [key]: value });
vscode.setState?.({ ...(vscode.getState?.() ?? {}), [key]: value });
};

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

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

0 comments on commit 0edb602

Please sign in to comment.