mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 12:02:44 +00:00
Modify folded text generation
This commit is contained in:
@@ -355,12 +355,24 @@ const CodeEditor = createClass({
|
|||||||
let text = '';
|
let text = '';
|
||||||
let currentLine = from.line;
|
let currentLine = from.line;
|
||||||
const maxLength = 50;
|
const maxLength = 50;
|
||||||
|
|
||||||
|
let headerText = '';
|
||||||
|
let otherText = '';
|
||||||
while (currentLine <= to.line && text.length <= maxLength) {
|
while (currentLine <= to.line && text.length <= maxLength) {
|
||||||
text += this.codeMirror.getLine(currentLine);
|
const currentText = this.codeMirror.getLine(currentLine);
|
||||||
if(currentLine < to.line)
|
currentLine++;
|
||||||
text += ' ';
|
if(!currentText) {
|
||||||
currentLine += 1;
|
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();
|
text = text.trim();
|
||||||
if(text.length > maxLength)
|
if(text.length > maxLength)
|
||||||
|
|||||||
Reference in New Issue
Block a user