From 28abd453ff7f6cf9b3ca35f74a2de6ff4e00d339 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijn@haverbeke.nl> Date: Thu, 19 May 2016 09:36:21 +0200 Subject: [PATCH] Only read lastCopied.lineWise when lastCopied matches clipboard Closes #4030 Closes #4031 --- lib/codemirror.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index c289defd1..6cca44657 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; -- GitLab