Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
- Move DEFAULT_READ_ARGUMENTS Into view-types.ts
- Ensure that value of address option field gets trimmed before requesting a memory update
- Dont render option field hints (Actual...) if the memory view is stil in intial state
  • Loading branch information
tortmayr committed May 6, 2024
1 parent 4a014fe commit 234d1e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/webview/components/options-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import { MemoryOptions, ReadMemoryArguments, SessionContext } from '../../common
import { tryToNumber } from '../../common/typescript';
import { CONFIG_BYTES_PER_MAU_CHOICES, CONFIG_GROUPS_PER_ROW_CHOICES, CONFIG_MAUS_PER_GROUP_CHOICES } from '../../plugin/manifest';
import { TableRenderOptions } from '../columns/column-contribution-service';
import { DEFAULT_READ_ARGUMENTS } from '../memory-webview-view';
import { AddressPaddingOptions, MemoryState, SerializedTableRenderOptions } from '../utils/view-types';
import { AddressPaddingOptions, DEFAULT_READ_ARGUMENTS, MemoryState, SerializedTableRenderOptions } from '../utils/view-types';
import { createSectionVscodeContext } from '../utils/vscode-contexts';
import { MultiSelectWithLabel } from './multi-select';

Expand Down Expand Up @@ -138,9 +137,11 @@ export class OptionsWidget extends React.Component<OptionsWidgetProps, OptionsWi
const readDisabled = isFrozen || !this.props.sessionContext.canRead;
const freezeContentToggleTitle = isFrozen ? 'Unfreeze Memory View' : 'Freeze Memory View';
const activeMemoryReadArgumentHint = (userValue: string | number, memoryValue: string | number): ReactNode | undefined => {
if (userValue !== memoryValue) {
return <small className="form-options-memory-read-argument-hint">Actual: {memoryValue}</small>;
if (userValue === memoryValue || this.props.activeReadArguments === DEFAULT_READ_ARGUMENTS) {
return undefined;
}
return <small className="form-options-memory-read-argument-hint">Actual: {memoryValue}</small>;

};

return (
Expand Down Expand Up @@ -442,12 +443,12 @@ export class OptionsWidget extends React.Component<OptionsWidgetProps, OptionsWi
this.props.updateMemoryState({
configuredReadArguments: {
...this.props.configuredReadArguments,
memoryReference: value,
memoryReference: value.trim(),
}
});
break;
case InputId.Offset:
if (!Number.isNaN(value)) {
if (!!value && !Number.isNaN(value)) {
this.props.updateMemoryState({
configuredReadArguments: {
...this.props.configuredReadArguments,
Expand All @@ -457,7 +458,7 @@ export class OptionsWidget extends React.Component<OptionsWidgetProps, OptionsWi
}
break;
case InputId.Length:
if (!Number.isNaN(value)) {
if (!!value && !Number.isNaN(value)) {
this.props.updateMemoryState({
configuredReadArguments: {
...this.props.configuredReadArguments,
Expand Down
9 changes: 1 addition & 8 deletions src/webview/memory-webview-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
logMessageType,
MemoryOptions,
memoryWrittenType,
ReadMemoryArguments,
readMemoryType,
readyType,
resetMemoryViewSettingsType,
Expand All @@ -51,7 +50,7 @@ import { AddressHover } from './hovers/address-hover';
import { DataHover } from './hovers/data-hover';
import { hoverService, HoverService } from './hovers/hover-service';
import { VariableHover } from './hovers/variable-hover';
import { Decoration, MemoryDisplayConfiguration, MemoryState } from './utils/view-types';
import { Decoration, DEFAULT_READ_ARGUMENTS, MemoryDisplayConfiguration, MemoryState } from './utils/view-types';
import { variableDecorator } from './variables/variable-decorations';
import { messenger } from './view-messenger';

Expand Down Expand Up @@ -82,12 +81,6 @@ const MEMORY_DISPLAY_CONFIGURATION_DEFAULTS: MemoryDisplayConfiguration = {
showRadixPrefix: true,
};

export const DEFAULT_READ_ARGUMENTS: Required<ReadMemoryArguments> = {
memoryReference: '',
offset: 0,
count: 256,
};

class App extends React.Component<{}, MemoryAppState> {
protected memoryWidget = React.createRef<MemoryWidget>();

Expand Down
6 changes: 6 additions & 0 deletions src/webview/utils/view-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export interface MemoryState {
isMemoryFetching: boolean;
}

export const DEFAULT_READ_ARGUMENTS: Required<ReadMemoryArguments> = {
memoryReference: '',
offset: 0,
count: 256,
};

export interface UpdateExecutor {
fetchData(currentViewParameters: ReadMemoryArguments): Promise<void>;
}
Expand Down

0 comments on commit 234d1e8

Please sign in to comment.