-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhances the context data of the context menu #135
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ export interface VscodeContext { | |
export type WebviewSection = 'optionsWidget' | 'advancedOptionsOverlay' | 'memoryTable'; | ||
|
||
export function createVscodeContext<C extends {}>(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<string, unknown> { | ||
|
@@ -60,8 +60,19 @@ export function createAppVscodeContext(context: Omit<WebviewContext, 'webviewSec | |
return createVscodeContext({ ...context, webviewSection: 'app', preventDefaultContextMenuItems: true }); | ||
} | ||
|
||
export function createGroupVscodeContext(startAddress: BigInt, length: number): VscodeContext { | ||
return createVscodeContext({ memoryData: { group: { startAddress, length } } }); | ||
} | ||
|
||
export function createVariableVscodeContext(variable: BigIntVariableRange): VscodeContext { | ||
const { name, type, value, isPointer } = variable; | ||
return createVscodeContext({ variable: { name, type, value, isPointer } }); | ||
} | ||
|
||
function replacerForBigInt(_: string, value: unknown): unknown { | ||
if (typeof value === 'bigint') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we always be sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment bigint seems to be used only for memory addresses and memory data. As Alternatively, we can also limit this formatting to the specific fields we currently know to be passed into the context, which would be fine too, if you prefer. |
||
return `0x${value.toString(16)}`; | ||
} | ||
return value; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*8
looked a bit off initially. But realized later that most internal calculations are still based on bits....