0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Reduce variable use

This commit is contained in:
G.Ambatte
2022-09-27 08:03:43 +13:00
parent 7b961af45f
commit 447f8d39dc

View File

@@ -356,23 +356,19 @@ const CodeEditor = createClass({
let currentLine = from.line;
const maxLength = 50;
let headerText = '';
let otherText = '';
let foldPreviewText = '';
while (currentLine <= to.line && text.length <= maxLength) {
const currentText = this.codeMirror.getLine(currentLine);
currentLine++;
if(!currentText) {
continue;
}
if(currentText[0] == '#'){
headerText = currentText;
foldPreviewText = currentText;
break;
}
if(!otherText && currentText != '\n') {
otherText = currentText;
if(!foldPreviewText && currentText != '\n') {
foldPreviewText = currentText;
}
}
text = headerText || otherText || `Lines ${from.line+1}-${to.line+1}`;
text = foldPreviewText || `Lines ${from.line+1}-${to.line+1}`;
text = text.trim();
if(text.length > maxLength)