vscode-annotator icon indicating copy to clipboard operation
vscode-annotator copied to clipboard

Move to the current line the source file being annotated

Open kavehv opened this issue 9 years ago • 6 comments

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

kavehv avatar Jul 14 '16 23:07 kavehv

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

ryu1kn avatar Jul 15 '16 10:07 ryu1kn

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 avatar Aug 08 '16 13:08 ryu1kn

  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.

ryu1kn avatar Aug 08 '16 13:08 ryu1kn

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

isg avatar Aug 19 '16 02:08 isg

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.

ryu1kn avatar Mar 08 '18 08:03 ryu1kn

@ryu1kn any updates on this ?

ctf0 avatar Aug 31 '20 08:08 ctf0