From eaa8ccaccb1091820d0a8d1223996a6dd057347d Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 17 Jan 2016 14:28:04 -0600 Subject: Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor --- public/vendor/codemirror/addon/comment/comment.js | 27 ++++++++++++++++------ .../codemirror/addon/comment/continuecomment.js | 0 2 files changed, 20 insertions(+), 7 deletions(-) mode change 100755 => 100644 public/vendor/codemirror/addon/comment/comment.js mode change 100755 => 100644 public/vendor/codemirror/addon/comment/continuecomment.js (limited to 'public/vendor/codemirror/addon/comment') diff --git a/public/vendor/codemirror/addon/comment/comment.js b/public/vendor/codemirror/addon/comment/comment.js old mode 100755 new mode 100644 index 2dd114d3..3aa46808 --- a/public/vendor/codemirror/addon/comment/comment.js +++ b/public/vendor/codemirror/addon/comment/comment.js @@ -21,22 +21,28 @@ } CodeMirror.commands.toggleComment = function(cm) { - var minLine = Infinity, ranges = cm.listSelections(), mode = null; + cm.toggleComment(); + }; + + CodeMirror.defineExtension("toggleComment", function(options) { + if (!options) options = noOptions; + var cm = this; + var minLine = Infinity, ranges = this.listSelections(), mode = null; for (var i = ranges.length - 1; i >= 0; i--) { var from = ranges[i].from(), to = ranges[i].to(); if (from.line >= minLine) continue; if (to.line >= minLine) to = Pos(minLine, 0); minLine = from.line; if (mode == null) { - if (cm.uncomment(from, to)) mode = "un"; - else { cm.lineComment(from, to); mode = "line"; } + if (cm.uncomment(from, to, options)) mode = "un"; + else { cm.lineComment(from, to, options); mode = "line"; } } else if (mode == "un") { - cm.uncomment(from, to); + cm.uncomment(from, to, options); } else { - cm.lineComment(from, to); + cm.lineComment(from, to, options); } } - }; + }); CodeMirror.defineExtension("lineComment", function(from, to, options) { if (!options) options = noOptions; @@ -57,7 +63,14 @@ self.operation(function() { if (options.indent) { - var baseString = firstLine.slice(0, firstNonWS(firstLine)); + var baseString = null; + for (var i = from.line; i < end; ++i) { + var line = self.getLine(i); + var whitespace = line.slice(0, firstNonWS(line)); + if (baseString == null || baseString.length > whitespace.length) { + baseString = whitespace; + } + } for (var i = from.line; i < end; ++i) { var line = self.getLine(i), cut = baseString.length; if (!blankLines && !nonWS.test(line)) continue; diff --git a/public/vendor/codemirror/addon/comment/continuecomment.js b/public/vendor/codemirror/addon/comment/continuecomment.js old mode 100755 new mode 100644 -- cgit v1.2.3