diff --git a/lib/codemirror.js b/lib/codemirror.js index c289defd14621d442df29e5d9e3afb71789cccc4..6cca44657ca2191e713ba828471d4006654ac46d 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1107,10 +1107,11 @@ if (!sel) sel = doc.sel; var paste = cm.state.pasteIncoming || origin == "paste"; - var textLines = doc.splitLines(inserted), multiPaste = null; + var textLines = doc.splitLines(inserted), multiPaste = null, lineWisePaste = false; // When pasing N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { if (lastCopied && lastCopied.text.join("\n") == inserted) { + lineWisePaste = lastCopied.lineWise if (sel.ranges.length % lastCopied.text.length == 0) { multiPaste = []; for (var i = 0; i < lastCopied.text.length; i++) @@ -1130,7 +1131,7 @@ from = Pos(from.line, from.ch - deleted); else if (cm.state.overwrite && !paste) // Handle overwrite to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); - else if (paste && lastCopied.lineWise && cm.options.lineWiseCopyCut) // Handle paste after lineWiseCopyCut + else if (lineWisePaste) from = to = Pos(from.line, 0) } var updateInput = cm.curOp.updateInput;