Added synced scrolling (#386)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
mrdrogdrog 2020-08-19 23:01:38 +02:00 committed by GitHub
parent 164b5436ae
commit 73007ef597
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 413 additions and 38 deletions

View file

@ -0,0 +1,25 @@
import { LineMarkerPosition } from '../../markdown-renderer/markdown-renderer'
export const findLineMarks = (lineMarks: LineMarkerPosition[], lineNumber: number): { lastMarkBefore: LineMarkerPosition | undefined, firstMarkAfter: LineMarkerPosition | undefined } => {
let lastMarkBefore
let firstMarkAfter
for (let i = 0; i < lineMarks.length; i++) {
const currentMark = lineMarks[i]
if (!currentMark) {
continue
}
if (currentMark.line <= lineNumber) {
lastMarkBefore = currentMark
}
if (currentMark.line > lineNumber) {
firstMarkAfter = currentMark
}
if (!!firstMarkAfter && !!lastMarkBefore) {
break
}
}
return {
lastMarkBefore,
firstMarkAfter
}
}