1
Fork 0

Prevent jumps when selecting one or many lines

This commit is contained in:
Stefan Schindler 2019-11-15 02:30:44 +01:00
parent 71cf364c3c
commit 1bbb8168ec

View file

@ -401,16 +401,21 @@ function getSearchElement() {
var prev_line_id = 0;
var set_fragment = function(name) {
var x = window.scrollX,
y = window.scrollY;
if (browserSupportsHistoryApi()) {
history.replaceState(null, null, "#" + name);
highlightSourceLines();
} else {
location.replace("#" + name);
}
// Prevent jumps when selecting one or many lines
window.scrollTo(x, y);
};
return function(ev) {
var cur_line_id = parseInt(ev.target.id, 10);
ev.preventDefault();
if (ev.shiftKey && prev_line_id) {
// Swap selection if needed