From b67dc1621bde848d9d340f6b6ad45d0a8e628a20 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 13 Nov 2021 20:57:33 -0500 Subject: [PATCH 1/2] More simplification to fold-code script --- shared/naturalcrit/codeEditor/fold-code.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shared/naturalcrit/codeEditor/fold-code.js b/shared/naturalcrit/codeEditor/fold-code.js index e43fda8ec..cff1c64e0 100644 --- a/shared/naturalcrit/codeEditor/fold-code.js +++ b/shared/naturalcrit/codeEditor/fold-code.js @@ -6,13 +6,12 @@ module.exports = { if(start.line === cm.firstLine() || prevLine.match(matcher)) { const lastLineNo = cm.lastLine(); - let end = start.line, nextLine = cm.getLine(start.line + 1); + let end = start.line; while (end < lastLineNo) { - if(nextLine.match(matcher)) + if(cm.getLine(end + 1).match(matcher)) break; ++end; - nextLine = cm.getLine(end + 1); } return { @@ -24,4 +23,4 @@ module.exports = { return null; }); } -}; \ No newline at end of file +}; From 1ec1ddc80c5036dee78ac7bc534ec7173bb73f6a Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Sun, 14 Nov 2021 09:58:41 -0600 Subject: [PATCH 2/2] Remove code fold toggling shortcut #629 --- shared/naturalcrit/codeEditor/codeEditor.jsx | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 5190e0b9e..01eca0114 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -74,20 +74,18 @@ const CodeEditor = createClass({ tabSize : 2, historyEventDelay : 250, extraKeys : { - 'Ctrl-B' : this.makeBold, - 'Cmd-B' : this.makeBold, - 'Ctrl-I' : this.makeItalic, - 'Cmd-I' : this.makeItalic, - 'Ctrl-M' : this.makeSpan, - 'Cmd-M' : this.makeSpan, - 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment, - 'Ctrl-\\' : this.toggleCodeFolded, - 'Cmd-\\' : this.toggleCodeFolded, - 'Ctrl-[' : this.foldAllCode, - 'Cmd-[' : this.foldAllCode, - 'Ctrl-]' : this.unfoldAllCode, - 'Cmd-]' : this.unfoldAllCode + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment, + 'Ctrl-[' : this.foldAllCode, + 'Cmd-[' : this.foldAllCode, + 'Ctrl-]' : this.unfoldAllCode, + 'Cmd-]' : this.unfoldAllCode }, foldGutter : true, foldOptions : { @@ -155,10 +153,6 @@ const CodeEditor = createClass({ } }, - toggleCodeFolded : function() { - this.codeMirror.foldCode(this.codeMirror.getCursor()); - }, - foldAllCode : function() { this.codeMirror.execCommand('foldAll'); },