diff options
author | Debayan Ganguly <dganguly1120@gmail.com> | 2022-11-10 00:48:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 00:48:39 +0300 |
commit | 54543cf5bf178600cfea17355b4c201877132b5b (patch) | |
tree | 8b84640658589960d1722a4091e2cccf6d383715 /extensions | |
parent | 78f6c8cdd31e1b90a99c2c2034041a0cea0e2767 (diff) |
Fix: New md file scrolls to Top. (#164999)
Fixes #164071.
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/markdown-language-features/preview-src/index.ts | 6 | ||||
-rw-r--r-- | extensions/markdown-language-features/src/preview/preview.ts | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/extensions/markdown-language-features/preview-src/index.ts b/extensions/markdown-language-features/preview-src/index.ts index 174a7d35692..2f0b0ba24e8 100644 --- a/extensions/markdown-language-features/preview-src/index.ts +++ b/extensions/markdown-language-features/preview-src/index.ts @@ -57,12 +57,12 @@ function doAfterImagesLoaded(cb: () => void) { } onceDocumentLoaded(() => { - const scrollProgress = state.scrollProgress; + const scrollTo = !isNaN(state.line) ? state.line : state.scrollProgress; - if (typeof scrollProgress === 'number' && !settings.settings.fragment) { + if (typeof scrollTo === 'number' && !settings.settings.fragment) { doAfterImagesLoaded(() => { scrollDisabledCount += 1; - window.scrollTo(0, scrollProgress * document.body.clientHeight); + window.scrollTo(0, scrollTo * document.body.clientHeight); }); return; } diff --git a/extensions/markdown-language-features/src/preview/preview.ts b/extensions/markdown-language-features/src/preview/preview.ts index 3d04c6db309..64d6e03b2b3 100644 --- a/extensions/markdown-language-features/src/preview/preview.ts +++ b/extensions/markdown-language-features/src/preview/preview.ts @@ -755,6 +755,8 @@ export class DynamicMarkdownPreview extends Disposable implements IManagedMarkdo default: return; } + } else if (!scrollLocation) { + scrollLocation = new StartingScrollLine(0); } this._preview.dispose(); |