1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Changes to optimize initial highlighting

Now iterates over highlighted lines instead of all lines of the snippet
This commit is contained in:
Duarte-Frazao
2018-12-06 13:23:23 +00:00
parent 1a0e15e04c
commit b5604ba0a9

View File

@@ -713,11 +713,16 @@ export default class CodeEditor extends React.Component {
return
}
const count = this.editor.lineCount()
for (let i = 0; i < count; i++) {
if (this.editor.options.linesHighlighted.includes(i)) {
this.editor.addLineClass(i, 'text', 'CodeMirror-activeline-background')
const totalHighlightedLines = this.editor.options.linesHighlighted.length
const totalAvailableLines = this.editor.lineCount()
for (let i = 0; i < totalHighlightedLines; i++) {
const lineNumber = this.editor.options.linesHighlighted[i]
if (lineNumber > totalAvailableLines) {
// make sure that we skip the invalid lines althrough this case should not be happened.
continue
}
this.editor.addLineClass(lineNumber, 'text', 'CodeMirror-activeline-background')
}
}