snips.sh
snips.sh copied to clipboard
Scroll to line on webpage if out of view
What is the feature or enhancement?
If you have a really long snippet and line(s) are selected, the page should jump to those lines.
Could use getSelectedLines somewhere after the other methods get called when the DOM loads:
https://github.com/robherley/snips.sh/blob/8e52e02c66e74479d5643d22a2c6490cd73a5b7f/web/static/js/snips.js#L103-L112
Something like this should work with better checks:
document.getElementById(`#L${theFirstSelectedLineHere}`).scrollIntoView();
Or if the menu/etc get in the way window.scroll to the element's bounding +/- some px should also work