Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 0877674

Browse files
committed
Simplify conditional check
1 parent c81b4e4 commit 0877674

File tree

1 file changed

+5
-5
lines changed
  • client/web-sveltekit/src/lib/codemirror

1 file changed

+5
-5
lines changed

client/web-sveltekit/src/lib/codemirror/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ export function getScrollSnapshot(view: EditorView): ScrollSnapshot {
105105
* @param snapshot The scroll snapshot
106106
*/
107107
export function restoreScrollSnapshot(view: EditorView, snapshot: ScrollSnapshot): void {
108-
if (snapshot.scrollTop !== undefined) {
109-
// We are using request measure here to ensure that the DOM has been updated/painted
108+
const {scrollTop} = snapshot
109+
110+
if (scrollTop !== undefined) {
111+
// We are using request measure here to ensure that the DOM has been updated
110112
// before updating the scroll position.
111113
view.requestMeasure({
112114
read() {
113115
return null
114116
},
115117
write(_measure, view) {
116-
if (snapshot.scrollTop !== undefined) {
117-
view.scrollDOM.scrollTop = snapshot.scrollTop
118-
}
118+
view.scrollDOM.scrollTop = scrollTop
119119
},
120120
})
121121
}

0 commit comments

Comments
 (0)