question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Markdown preview does not scroll to top on new URI

See original GitHub issue

Does this issue occur when all extensions are disabled?: N/A (depends on the built-in markdown extension)

  • VS Code Version: 1.72.1
  • OS Version: macOS 12.4

Steps to Reproduce:

  1. Create two Markdown documents, one with a relative link to the other, and enough content in both documents to scroll down
  2. Preview the document with the link and scroll down to the link, then click it

Expected Behavior:

The link to the other document should open the new document at the top

Actual Behavior:

The scroll position stays the same, opening the new document at a random spot in that document

Other Information:

This change is probably straightforward to make, but it would break the existing behavior. I’m struggling to imagine why that behavior would be desirable though, so not sure it would actually affect anyone in a meaningful way.

cc @mjbvz

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
GauravB159commented, Oct 29, 2022

Hello, I’m new to Open Source development and I was going through the Good First Issue label and figured I could take a crack at this one.

I think I have traced the problem back to this section of code, but I’m not sure how to proceed.

image

This is in the file “extensions\markdown-language-features\preview-src\index.ts”

It seems the scrollProgress of a preview window is stored in a state variable and when the link is clicked, the scrollProgress is restored using that piece of code. I’m not sure if that is intended behavior, or a bug fix for another issue.

Commenting out line 65 actually solves the issue, but again, I am not sure if the line was added for some other bug fix or intended behavior, since the commit message for that line does not specify a bug fix.

cc: @dsanders11

1reaction
LoopThrough-i-jcommented, Oct 23, 2022

@dsanders11 I tried digging into the issue and found that because it is an in-place reload of the Preview, the scroll bar tries to get back to its original position after rerendering. Do you recommend opening a new tab for the linked document’s preview, that would ideally solve the issue.

P.S. I tried setting the StartScrollLine number of the linked document to 0 before rerendering but it didn’t seem to work.

cc. @mjbvz

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCODE -- has anyone figured out how to stop markdown ...
What I've found is that the preview does not track the location that is in view in the editor, so I have to...
Read more >
January 2021 (version 1.53) - Visual Studio Code
Markdown preview auto updates when images are changed on disk. The Markdown preview will now automatically update when any embedded images are changed...
Read more >
Preview - Dendron
The Dendron Preview gives you a rich HTML preview for your notes. Details. when a note is open by clicking a link in...
Read more >
Markdown - vscode-docs1 - Read the Docs
Additionally, double clicking an element in the Markdown preview will automatically open the editor for the file and scroll to the line nearest...
Read more >
Untitled
Image caps # Similar to headers and footers, cards can include top and bottom ... Scroll 80 React Markdown Editor Lite Attaching non-image...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found