From 2d30ac21a761837535803b13a5c2a1d6a5806c18 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Thu, 11 Nov 2021 17:08:05 -0600 Subject: [PATCH] Update code based on PR feedback #692 --- client/homebrew/editor/editor.jsx | 2 +- shared/naturalcrit/codeEditor/codeEditor.jsx | 10 +++++++--- shared/naturalcrit/codeEditor/codeEditor.less | 2 ++ shared/naturalcrit/codeEditor/fold-code.js | 8 ++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 61d330772..14038f740 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -108,7 +108,7 @@ const Editor = createClass({ const codeMirror = this.refs.codeEditor.codeMirror; //reset custom text styles - const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); + const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=0;i{ diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 3fdfec252..5190e0b9e 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -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'] diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index 5c0680349..0ad7a27f8 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -4,5 +4,7 @@ .codeEditor{ .CodeMirror-foldmarker { font-family: inherit; + text-shadow: none; + font-weight: 600; } } \ No newline at end of file diff --git a/shared/naturalcrit/codeEditor/fold-code.js b/shared/naturalcrit/codeEditor/fold-code.js index f7e8b0901..e43fda8ec 100644 --- a/shared/naturalcrit/codeEditor/fold-code.js +++ b/shared/naturalcrit/codeEditor/fold-code.js @@ -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); }