From 447f8d39dccf1674df2e598a3a6a9827c457820f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 27 Sep 2022 08:03:43 +1300 Subject: [PATCH] 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)