File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
extensions/markdown-language-features/preview-src Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,13 @@ let documentResource = settings.settings.source;
23
23
const vscode = acquireVsCodeApi ( ) ;
24
24
25
25
const originalState = vscode . getState ( ) ?? { } as any ;
26
-
27
26
const state = {
28
- originalState,
27
+ ... originalState ,
29
28
...getData < any > ( 'data-state' )
30
29
} ;
31
30
32
- if ( originalState ?. resource !== state . resource ) {
33
- state . scrollProgress = undefined ;
31
+ if ( typeof originalState . scrollProgress !== 'undefined' && originalState ?. resource !== state . resource ) {
32
+ state . scrollProgress = 0 ;
34
33
}
35
34
36
35
// Make sure to sync VS Code state here
@@ -67,7 +66,9 @@ onceDocumentLoaded(() => {
67
66
if ( typeof scrollProgress === 'number' && ! settings . settings . fragment ) {
68
67
doAfterImagesLoaded ( ( ) => {
69
68
scrollDisabledCount += 1 ;
70
- window . scrollTo ( 0 , scrollProgress * document . body . clientHeight ) ;
69
+ // Always set scroll of at least 1 to prevent VS Code's webview code from auto scrolling us
70
+ const scrollToY = Math . max ( 1 , scrollProgress * document . body . clientHeight ) ;
71
+ window . scrollTo ( 0 , scrollToY ) ;
71
72
} ) ;
72
73
return ;
73
74
}
You can’t perform that action at this time.
0 commit comments