0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 21:42:44 +00:00

Update code based on PR feedback

#692
This commit is contained in:
Charlie Humphreys
2021-11-11 17:08:05 -06:00
parent 52d7e6892b
commit 2d30ac21a7
4 changed files with 12 additions and 10 deletions

View File

@@ -91,6 +91,7 @@ const CodeEditor = createClass({
},
foldGutter : true,
foldOptions : {
scanUp : true,
rangeFinder : CodeMirror.fold.homebrewery,
widget : (from, to)=>{
let text = '';
@@ -98,13 +99,16 @@ const CodeEditor = createClass({
const maxLength = 50;
while (currentLine <= to.line && text.length <= maxLength) {
text += this.codeMirror.getLine(currentLine);
if(currentLine < to.line) {
if(currentLine < to.line)
text += ' ';
}
currentLine += 1;
}
return `\u21A4${text.substr(0, maxLength)}\u21A6`;
text = text.trim();
if(text.length > maxLength)
text = `${text.substr(0, maxLength)}...`;
return `\u21A4 ${text} \u21A6`;
}
},
gutters : ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']

View File

@@ -4,5 +4,7 @@
.codeEditor{
.CodeMirror-foldmarker {
font-family: inherit;
text-shadow: none;
font-weight: 600;
}
}

View File

@@ -9,12 +9,8 @@ module.exports = {
let end = start.line, nextLine = cm.getLine(start.line + 1);
while (end < lastLineNo) {
if(nextLine.match(matcher)) {
return {
from : CodeMirror.Pos(start.line, 0),
to : CodeMirror.Pos(end, cm.getLine(end).length)
};
}
if(nextLine.match(matcher))
break;
++end;
nextLine = cm.getLine(end + 1);
}