diff options
Diffstat (limited to 'public/vendor/codemirror/addon/wrap')
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/wrap/hardwrap.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/public/vendor/codemirror/addon/wrap/hardwrap.js b/public/vendor/codemirror/addon/wrap/hardwrap.js index fe9b4dd6..8806fbe2 100755..100644 --- a/public/vendor/codemirror/addon/wrap/hardwrap.js +++ b/public/vendor/codemirror/addon/wrap/hardwrap.js @@ -32,11 +32,13 @@ function findBreakPoint(text, column, wrapOn, killTrailingSpace) { for (var at = column; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; - if (at == 0) at = column; - var endOfText = at; - if (killTrailingSpace) - while (text.charAt(endOfText - 1) == " ") --endOfText; - return {from: endOfText, to: at}; + for (var first = true;; first = false) { + var endOfText = at; + if (killTrailingSpace) + while (text.charAt(endOfText - 1) == " ") --endOfText; + if (endOfText == 0 && first) at = column; + else return {from: endOfText, to: at}; + } } function wrapRange(cm, from, to, options) { @@ -86,7 +88,8 @@ if (changes.length) cm.operation(function() { for (var i = 0; i < changes.length; ++i) { var change = changes[i]; - cm.replaceRange(change.text, change.from, change.to); + if (change.text || CodeMirror.cmpPos(change.from, change.to)) + cm.replaceRange(change.text, change.from, change.to); } }); return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null; |