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

Move to the current line the source file being annotated #2

Open
kavehv opened this issue Jul 14, 2016 · 6 comments
Open

Move to the current line the source file being annotated #2

kavehv opened this issue Jul 14, 2016 · 6 comments

Comments

@kavehv
Copy link

kavehv commented Jul 14, 2016

When invoked, annotate should travel to the line number the cursor currently resides on in the source file annotate was invoked upon.

@ryu1kn
Copy link
Owner

ryu1kn commented Jul 15, 2016

Yeah it would be nice if we have this especially when you work on a large file.

@ryu1kn
Copy link
Owner

ryu1kn commented Aug 8, 2016

If I add this in the html, I can open annotation view already scrolled to the specified lineNumber.

var selector = '.line:nth-of-type(' + lineNumber + ')';
window.scrollTo(0, document.querySelector(selector).offsetTop)

But because the html view doesn't retain its scroll position, if you set the initial line to X with the above script, the following happens.

  1. Scroll the annotation view (to line Y)
  2. Switch to another document
  3. Switch back to the annotation view, you are not at line Y but X.

Although it's not great, I think it's better to always show at the top of the annotation view rather than to show at line X which I would probably forget by the time I switch back to the view and would then get confused why I'm seeing the line X.

It happens with Markdown Preview page as well. If I leave and come back to the preview, scroll position goes back to the page top. It retains the scroll position if you open the preview along with the markdown editor. I need to check if it's intended/ideal behaviour in vscode issues.

@ryu1kn
Copy link
Owner

ryu1kn commented Aug 8, 2016

  1. Switch back to the annotation view, you are not at line Y but X.

By the way, at this timing, the window.scrollTo( gets executed twice.

@isg
Copy link

isg commented Aug 19, 2016

Yeah this would be super useful (and thanks for the great extension as is!)

@ryu1kn
Copy link
Owner

ryu1kn commented Mar 8, 2018

But because the html view doesn't retain its scroll position, if you set the initial line to X with the above script, the following happens.

  1. Scroll the annotation view (to line Y)
  2. Switch to another document
  3. Switch back to the annotation view, you are not at line Y but X.

...

It happens with Markdown Preview page as well. If I leave and come back to the preview, scroll position goes back to the page top. It retains the scroll position if you open the preview along with the markdown editor. I need to check if it's intended/ideal behaviour in vscode issues.

This is fixed in VS Code 1.21! So the original request can be implemented.

@ctf0
Copy link

ctf0 commented Aug 31, 2020

@ryu1kn any updates on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants