Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown Preview does not preserve scroll position #22995

Closed
danieljl opened this issue Mar 22, 2017 · 9 comments · Fixed by #26426
Closed

Markdown Preview does not preserve scroll position #22995

danieljl opened this issue Mar 22, 2017 · 9 comments · Fixed by #26426
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug markdown Markdown support issues plan-item VS Code - planned item for upcoming verified Verification succeeded webview Webview issues
Milestone

Comments

@danieljl
Copy link

danieljl commented Mar 22, 2017

  • VSCode Version: 1.10.2
  • OS Version: Ubuntu 14.04

Steps to Reproduce:

  1. Open a Markdown file.
  2. Open the preview (ctrl+shift+v).
  3. Close the Markdown file tab (not the preview).
  4. Scroll a few times in the preview tab.
  5. Open any other file.
  6. Go to the preview tab again. Notice that the scrollbar is reset to top.

My suggestion is that the scroll position of Markdown preview tab should follow its corresponding raw Markdown tab's only if the raw Markdown tab is present. If it is not present, the preview tab should preserve the last scroll position.

@mjbvz mjbvz added the markdown Markdown support issues label Mar 22, 2017
@mjbvz mjbvz added the webview Webview issues label Apr 6, 2017
@slfuqua
Copy link

slfuqua commented Apr 9, 2017

  • VSCode Version: 1.11.1
  • OS Version: Ubuntu 14.04

Steps to Reproduce:

  1. Open a Markdown file, place cursor anywhere in file other than the top
  2. Open the Preview (ctrl+shift+v).

More generally than above, the "Preview" tool now (unlike previously) always resets to the top of the markdown file when you open it or go to its tab and it refreshes (or you press ctrl+shift+v). It no longer goes to the current edit (cursor) location in the raw file. It is inconvenient to repeatedly scroll down to the current edit location in long files, to preview the changes.

I'm pretty sure I skipped a couple of version updates until I installed 1.11.1 today (4/9/2017), so I'm not sure when the behavior changed, but it was fairly recent, my version was not too outdated, no more than two or three updates.

@jdim
Copy link

jdim commented Apr 9, 2017

Same behavior

  • VSCode Version: 1.12.0-insider
  • OS Version: Ubuntu 16.04

@rebornix
Copy link
Member

Re #22279, run into this issue while following the guidance of the project.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 11, 2017

@rebornix Can we try debugging through the issue on your machine this afternoon?

@chaskim
Copy link

chaskim commented Apr 18, 2017

I have the same problem as outlined by @slfuqua.

  • VS Code 1.11.2
  • macOS 10.11.6

It worked okay in earlier versions of VS Code (I believe it worked okay in 1.10.x).

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 19, 2017

For anyone seeing this problem, #24985 just added some basic logging to help investigate. The change be in the next insiders build. Once that is released, please download it and:

  • Set "markdown.trace": "verbose"
  • Reproduce the issue
  • Go to the output pane and share the output from the Markdown section

This should help me investigate what may be going wrong here

@mjbvz mjbvz closed this as completed Apr 19, 2017
@mjbvz mjbvz reopened this Apr 19, 2017
@chaskim
Copy link

chaskim commented Apr 19, 2017

@mjbvz Thanks very much for looking into this. Below is my output after setting markdown.trace to verbose in VS Code 1.12.0-insider. The first entry is when I click somewhere in the middle of the markdown document. The second is when I use the preview option (which still shows the very top of the document instead of where my cursor was in the actual markdown document).

[Log - 11:43:07 AM] updatePreviewForSelection
{
  "markdownFile": "markdown:/Users/Charles/Develop/Personnel/BlocNotes/aurelia-snippets.md.rendered?file%3A%2F%2F%2FUsers%2FCharles%2FDevelop%2FPersonnel%2FBlocNotes%2Faurelia-snippets.md"
}
[Log - 11:43:10 AM] provideTextDocumentContent
{
  "previewUri": "markdown:/Users/Charles/Develop/Personnel/BlocNotes/aurelia-snippets.md.rendered?file%3A%2F%2F%2FUsers%2FCharles%2FDevelop%2FPersonnel%2FBlocNotes%2Faurelia-snippets.md",
  "source": "file:///Users/Charles/Develop/Personnel/BlocNotes/aurelia-snippets.md",
  "line": 0,
  "scrollPreviewWithEditorSelection": true,
  "scrollEditorWithPreview": true,
  "doubleClickToSwitchToEditor": true
}

I see that the "line" entry is zero. Maybe the issue is related to that?

@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Apr 19, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 19, 2017

Thanks @chaskim!

From your log, I think there's a bug in the markdown preview where using Open Preview instead of Open Preview to Side causes the initial line not to be set. Looking into a fix

@kieferrm kieferrm mentioned this issue May 5, 2017
44 tasks
@isidorn
Copy link
Contributor

isidorn commented May 8, 2017

Potentially dup of #22420

@mjbvz mjbvz added this to the May 2017 milestone May 11, 2017
mjbvz added a commit to mjbvz/vscode that referenced this issue May 17, 2017
Fixes microsoft#22995

**Bug**
If you switch away from an editor that users a webview, the scroll position is currently not preserved. This effects our release notes and the markdown preview. The root cause is that the webview is disposed of when the view is hidden.

**Fix**
Add some presisted state to track scrollProgress through the webview. Use this state in the standard html editor and in the release notes.
mjbvz added a commit to mjbvz/vscode that referenced this issue May 17, 2017
Fixes microsoft#22995

**Bug**
If you switch away from an editor that users a webview, the scroll position is currently not preserved. This effects our release notes and the markdown preview. The root cause is that the webview is disposed of when the view is hidden.

**Fix**
Add some presisted state to track scrollProgress through the webview. Use this state in the standard html editor and in the release notes.
mjbvz added a commit that referenced this issue May 17, 2017
* Preserve Webview Scroll Position

Fixes #22995

**Bug**
If you switch away from an editor that users a webview, the scroll position is currently not preserved. This effects our release notes and the markdown preview. The root cause is that the webview is disposed of when the view is hidden.

**Fix**
Add some presisted state to track scrollProgress through the webview. Use this state in the standard html editor and in the release notes.

* Use view state

* Continue prototype memento based approach

* Preserve Webview Scroll Position

Fixes #22995

**Bug**
If you switch away from an editor that users a webview, the scroll position is currently not preserved. This effects our release notes and the markdown preview. The root cause is that the webview is disposed of when the view is hidden.

**Fix**
Add some presisted state to track scrollProgress through the webview. Use this state in the standard html editor and in the release notes.

* Revert changes to ReleaseNotesInput
@mjbvz mjbvz added the plan-item VS Code - planned item for upcoming label May 26, 2017
@michelkaporin michelkaporin added the verified Verification succeeded label Jun 2, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug markdown Markdown support issues plan-item VS Code - planned item for upcoming verified Verification succeeded webview Webview issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants