From 227be5e3beb66bea16ce45050cf9977cfa658ad6 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 25 Sep 2022 13:55:46 +1300 Subject: [PATCH 1/3] Modify folded text generation --- shared/naturalcrit/codeEditor/codeEditor.jsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 6340a58fe..46f24135b 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -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) From 1dc6256aab9f3dd3ba35e0107a593ad28bce42f9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 25 Sep 2022 19:59:35 +1300 Subject: [PATCH 2/3] Change fold-marker color to grey --- shared/naturalcrit/codeEditor/codeEditor.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index c929e0d21..1334299e4 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -13,7 +13,8 @@ font-family: inherit; text-shadow: none; font-weight: 600; - } + color: grey; +} .sourceMoveFlash .CodeMirror-line{ animation-name: sourceMoveAnimation; From 447f8d39dccf1674df2e598a3a6a9827c457820f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 27 Sep 2022 08:03:43 +1300 Subject: [PATCH 3/3] Reduce variable use --- shared/naturalcrit/codeEditor/codeEditor.jsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 46f24135b..da1390511 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -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)