Fix markdown preview restoring to wrong position on restart

This commit is contained in:
Matt Bierner
2019-02-14 18:23:35 -08:00
parent 714192fdc3
commit 003521e715
6 changed files with 24 additions and 17 deletions

View File

@@ -24,13 +24,13 @@ const getCodeLineElements = (() => {
let elements: CodeLineElement[];
return () => {
if (!elements) {
elements = ([{ element: document.body, line: 0 }]).concat(Array.prototype.map.call(
document.getElementsByClassName('code-line'),
(element: any) => {
const line = +element.getAttribute('data-line');
return { element, line };
})
.filter((x: any) => !isNaN(x.line)));
elements = [{ element: document.body, line: 0 }];
for (const element of document.getElementsByClassName('code-line')) {
const line = +element.getAttribute('data-line')!;
if (!isNaN(line)) {
elements.push({ element: element as HTMLElement, line });
}
}
}
return elements;
};