Skip to content

Commit e02b946

Browse files
committed
Also split pasted content by selection when selection length is a multiple of clipboard length
Issue #2697
1 parent 1d4b525 commit e02b946

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/codemirror.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,7 @@
24172417
var multiPaste = null;
24182418
if (cm.state.pasteIncoming && doc.sel.ranges.length > 1) {
24192419
if (lastCopied && lastCopied.join("\n") == inserted)
2420-
multiPaste = lastCopied.length == doc.sel.ranges.length && map(lastCopied, splitLines);
2420+
multiPaste = doc.sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
24212421
else if (textLines.length == doc.sel.ranges.length)
24222422
multiPaste = map(textLines, function(l) { return [l]; });
24232423
}
@@ -2433,7 +2433,7 @@
24332433
else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming)
24342434
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
24352435
var updateInput = cm.curOp.updateInput;
2436-
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i] : textLines,
2436+
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
24372437
origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
24382438
makeChange(cm.doc, changeEvent);
24392439
signalLater(cm, "inputRead", cm, changeEvent);

0 commit comments

Comments
 (0)