0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Modify folded text generation

This commit is contained in:
G.Ambatte
2022-09-25 13:55:46 +13:00
parent 6ade9925d7
commit 227be5e3be

View File

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