Move to the current line the source file being annotated
When invoked, annotate should travel to the line number the cursor currently resides on in the source file annotate was invoked upon.
Yeah it would be nice if we have this especially when you work on a large file.
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.
- Scroll the annotation view (to line
Y) - Switch to another document
- Switch back to the annotation view, you are not at line
YbutX.
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.
- 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.
Yeah this would be super useful (and thanks for the great extension as is!)
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.
- Scroll the annotation view (to line Y)
- Switch to another document
- 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 any updates on this ?