Skip to content

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

Open
@kavehv

Description

@kavehv

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

Activity

ryu1kn

ryu1kn commented on Jul 15, 2016

@ryu1kn
Owner

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

ryu1kn

ryu1kn commented on Aug 8, 2016

@ryu1kn
Owner

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

ryu1kn commented on Aug 8, 2016

@ryu1kn
Owner
  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

isg commented on Aug 19, 2016

@isg

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

ryu1kn

ryu1kn commented on Mar 8, 2018

@ryu1kn
Owner

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

ctf0 commented on Aug 31, 2020

@ctf0

@ryu1kn any updates on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kavehv@isg@ryu1kn@ctf0

        Issue actions

          Move to the current line the source file being annotated · Issue #2 · ryu1kn/vscode-annotator