Skip to content

Commit

Permalink
Alternative solution with debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
haydar-metin committed Mar 12, 2024
1 parent 107babd commit 50dfbfc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions media/memory-table.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
font-family: var(--vscode-editor-font-family);
}

.memory-inspector-table span.eight-bits {
white-space: nowrap;
}

/* == MoreMemorySelect == */

.bytes-select {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@vscode/codicons": "^0.0.32",
"fast-deep-equal": "^3.1.3",
"formik": "^2.4.5",
"lodash": "^4.17.21",
"memoize-one": "^6.0.0",
"primeflex": "^3.3.1",
"primereact": "^10.3.1",
Expand All @@ -45,6 +46,7 @@
"vscode-messenger-webview": "^0.4.3"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/node": "^12.20.0",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
Expand Down
17 changes: 11 additions & 6 deletions src/webview/components/memory-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { tryToNumber } from '../../common/typescript';
import { DataColumn } from '../columns/data-column';
import { createColumnVscodeContext, createSectionVscodeContext } from '../utils/vscode-contexts';
import { WebviewSelection } from '../../common/messaging';
import { debounce } from 'lodash';

export interface MoreMemorySelectProps {
activeReadArguments: Required<DebugProtocol.ReadMemoryArguments>;
Expand Down Expand Up @@ -199,14 +200,18 @@ export class MemoryTable extends React.PureComponent<MemoryTableProps, MemoryTab
}

componentDidMount(): void {
const handleResize = debounce(() => {
this.autofitColumns();

// The size changed - we could have too few rows visible to enable a scrollbar
if (this.props.scrollingBehavior === 'Auto-Append') {
this.ensureSufficientVisibleRowsForScrollbar();
}
}, 100);

this.resizeObserver = new ResizeObserver(entries => {
if (entries.length > 0) {
this.autofitColumns();

// The size changed - we could have too few rows visible to enable a scrollbar
if (this.props.scrollingBehavior === 'Auto-Append') {
this.ensureSufficientVisibleRowsForScrollbar();
}
handleResize();
}
});

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/lodash@^4.14.202":
version "4.14.202"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8"
integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==

"@types/node@*":
version "18.11.10"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.10.tgz#4c64759f3c2343b7e6c4b9caf761c7a3a05cee34"
Expand Down

0 comments on commit 50dfbfc

Please sign in to comment.