Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't do overwrite when pasting

  • Loading branch information...
commit 64d2081a713a37bb13607cb70a9742d64bbaa4cc 1 parent e8b2cb7
@marijnh marijnh authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/codemirror.js
View
7 lib/codemirror.js
@@ -75,7 +75,7 @@ window.CodeMirror = (function() {
// Selection-related flags. shiftSelecting obviously tracks
// whether the user is holding shift.
var shiftSelecting, lastClick, lastDoubleClick, lastScrollTop = 0, draggingText,
- overwrite = false, suppressEdits = false;
+ overwrite = false, suppressEdits = false, pasteIncoming = false;
// Variables used by startOperation/endOperation to track what
// happened during the operation.
var updateInput, userSelChange, changes, textChanged, selectionChanged,
@@ -128,7 +128,7 @@ window.CodeMirror = (function() {
connect(scroller, "drop", operation(onDrop));
}
connect(scroller, "paste", function(){focusInput(); fastPoll();});
- connect(input, "paste", fastPoll);
+ connect(input, "paste", function(){pasteIncoming = true; fastPoll();});
connect(input, "cut", operation(function(){
if (!options.readOnly) replaceSelection("");
}));
@@ -955,12 +955,13 @@ window.CodeMirror = (function() {
while (same < l && prevInput[same] == text[same]) ++same;
if (same < prevInput.length)
sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
- else if (overwrite && posEq(sel.from, sel.to))
+ else if (overwrite && posEq(sel.from, sel.to) && !pasteIncoming)
sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
replaceSelection(text.slice(same), "end");
if (text.length > 1000) { input.value = prevInput = ""; }
else prevInput = text;
if (!nestedOperation) endOperation();
+ pasteIncoming = false;
return true;
}
function resetInput(user) {
Please sign in to comment.
Something went wrong with that request. Please try again.