From cf8befbb7968073999796e5a1c65b1fc23913d31 Mon Sep 17 00:00:00 2001 From: Martin Fleck Date: Thu, 18 Apr 2024 13:21:36 +0200 Subject: [PATCH] PR Feedback - Improve wording in setting descriptions - Move shared types into common area instead of using type imports - Fix 'fetchMemory' not returning the correct promise --- package.json | 2 +- src/common/webview-configuration.ts | 46 +++++++++++++++++++++++++++++ src/plugin/memory-webview-main.ts | 2 +- src/webview/memory-webview-view.tsx | 2 +- src/webview/utils/view-types.ts | 32 ++------------------ 5 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 src/common/webview-configuration.ts diff --git a/package.json b/package.json index 9c64ed6..f87d701 100644 --- a/package.json +++ b/package.json @@ -260,7 +260,7 @@ ], "enumDescriptions": [ "Refresh when the debugger stops (e.g. a breakpoint is hit)", - "Refresh automatically when the view is newly focussed.", + "Refresh automatically each time the view receives focus.", "Refresh automatically after the configured `#memory-inspector.autoRefreshDelay#`", "Memory Inspector needs to be manually refreshed by the user" ], diff --git a/src/common/webview-configuration.ts b/src/common/webview-configuration.ts new file mode 100644 index 0000000..4d58ebb --- /dev/null +++ b/src/common/webview-configuration.ts @@ -0,0 +1,46 @@ +/******************************************************************************** + * Copyright (C) 2024 EclipseSource and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the Eclipse + * Public License v. 2.0 are satisfied: GNU General Public License, version 2 + * with the GNU Classpath Exception which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + ********************************************************************************/ +import { WebviewIdMessageParticipant } from 'vscode-messenger-common'; +import { AutoRefresh, Endianness, GroupsPerRowOption } from './manifest'; +import { Radix } from './memory-range'; + +/** The memory display configuration that can be specified for the memory widget. */ +export interface MemoryDisplayConfiguration { + bytesPerMau: number; + mausPerGroup: number; + groupsPerRow: GroupsPerRowOption; + endianness: Endianness; + scrollingBehavior: ScrollingBehavior; + addressPadding: AddressPadding; + addressRadix: Radix; + showRadixPrefix: boolean; + autoRefresh: AutoRefresh; + autoRefreshDelay: number; +} + +export type ScrollingBehavior = 'Paginate' | 'Grow' | 'Auto-Append'; + +export type AddressPadding = 'Minimal' | number; + +export interface ColumnVisibilityStatus { + visibleColumns: string[]; +} + +/** All settings related to memory view that can be specified for the webview from the extension "main". */ +export interface MemoryViewSettings extends ColumnVisibilityStatus, MemoryDisplayConfiguration { + title: string + messageParticipant: WebviewIdMessageParticipant; +} diff --git a/src/plugin/memory-webview-main.ts b/src/plugin/memory-webview-main.ts index 58f128c..44196da 100644 --- a/src/plugin/memory-webview-main.ts +++ b/src/plugin/memory-webview-main.ts @@ -46,8 +46,8 @@ import { WriteMemoryResult, writeMemoryType, } from '../common/messaging'; +import { MemoryViewSettings, ScrollingBehavior } from '../common/webview-configuration'; import { getVisibleColumns, WebviewContext } from '../common/webview-context'; -import type { MemoryViewSettings, ScrollingBehavior } from '../webview/utils/view-types'; import { isVariablesContext } from './external-views'; import { outputChannelLogger } from './logger'; import { MemoryProvider } from './memory-provider'; diff --git a/src/webview/memory-webview-view.tsx b/src/webview/memory-webview-view.tsx index d7e4c71..eec3a2c 100644 --- a/src/webview/memory-webview-view.tsx +++ b/src/webview/memory-webview-view.tsx @@ -303,7 +303,7 @@ class App extends React.Component<{}, MemoryAppState> { // may happen when we initialize empty return; } - this.doFetchMemory(completeOptions); + return this.doFetchMemory(completeOptions); }; protected async doFetchMemory(memoryOptions: Required): Promise { diff --git a/src/webview/utils/view-types.ts b/src/webview/utils/view-types.ts index 94f0cb2..b5c4684 100644 --- a/src/webview/utils/view-types.ts +++ b/src/webview/utils/view-types.ts @@ -16,11 +16,11 @@ import deepequal from 'fast-deep-equal'; import type * as React from 'react'; -import { WebviewIdMessageParticipant } from 'vscode-messenger-common'; -import { AutoRefresh, Endianness, GroupsPerRowOption } from '../../common/manifest'; +import { Endianness } from '../../common/manifest'; import { Memory } from '../../common/memory'; -import { areRangesEqual, BigIntMemoryRange, Radix } from '../../common/memory-range'; +import { areRangesEqual, BigIntMemoryRange } from '../../common/memory-range'; import { ReadMemoryArguments } from '../../common/messaging'; +import { MemoryDisplayConfiguration } from '../../common/webview-configuration'; export interface SerializedTableRenderOptions extends MemoryDisplayConfiguration { columnOptions: Array<{ label: string, doRender: boolean }>; @@ -73,28 +73,6 @@ export interface FullNodeAttributes extends StylableNodeAttributes { content: string; } -/** All settings related to memory view that can be specified for the webview from the extension "main". */ -export interface MemoryViewSettings extends ColumnVisibilityStatus, MemoryDisplayConfiguration { - title: string - messageParticipant: WebviewIdMessageParticipant; -} - -/** The memory display configuration that can be specified for the memory widget. */ -export interface MemoryDisplayConfiguration { - bytesPerMau: number; - mausPerGroup: number; - groupsPerRow: GroupsPerRowOption; - endianness: Endianness; - scrollingBehavior: ScrollingBehavior; - addressPadding: AddressPadding; - addressRadix: Radix; - showRadixPrefix: boolean; - autoRefresh: AutoRefresh; - autoRefreshDelay: number; -} -export type ScrollingBehavior = 'Paginate' | 'Grow' | 'Auto-Append'; - -export type AddressPadding = 'Minimal' | number; export const AddressPaddingOptions = { 'Minimal': 'Minimal', 'Unpadded': 0, @@ -102,10 +80,6 @@ export const AddressPaddingOptions = { '64bit': 64, } as const; -export interface ColumnVisibilityStatus { - visibleColumns: string[]; -} - export type ReactInteraction = React.MouseEvent | React.KeyboardEvent; export function isTrigger(event: ReactInteraction): boolean {