mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-154425 copy-paste in column mode bug
This commit is contained in:
+9
-7
@@ -83,6 +83,7 @@ public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
if (text == null) return null;
|
||||
|
||||
if (editor.getCaretModel().supportsMultipleCarets()) {
|
||||
CaretStateTransferableData caretData = null;
|
||||
int caretCount = editor.getCaretModel().getCaretCount();
|
||||
if (caretCount == 1 && editor.isColumnMode()) {
|
||||
int pastedLineCount = LineTokenizer.calcLineCount(text, true);
|
||||
@@ -96,13 +97,14 @@ public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
}
|
||||
caretCount = editor.getCaretModel().getCaretCount();
|
||||
}
|
||||
CaretStateTransferableData caretData = null;
|
||||
try {
|
||||
caretData = content.isDataFlavorSupported(CaretStateTransferableData.FLAVOR)
|
||||
? (CaretStateTransferableData)content.getTransferData(CaretStateTransferableData.FLAVOR) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
else {
|
||||
try {
|
||||
caretData = content.isDataFlavorSupported(CaretStateTransferableData.FLAVOR)
|
||||
? (CaretStateTransferableData)content.getTransferData(CaretStateTransferableData.FLAVOR) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
final TextRange[] ranges = new TextRange[caretCount];
|
||||
final Iterator<String> segments = new ClipboardTextPerCaretSplitter().split(text, caretData, caretCount).iterator();
|
||||
|
||||
+15
@@ -298,6 +298,21 @@ public class EditorMultiCaretColumnModeTest extends AbstractEditorTest {
|
||||
"ccccc");
|
||||
}
|
||||
|
||||
public void testPasteOfSeveralLinesCopiedFromIdeaToASingleCaret() throws Exception {
|
||||
init("a\n" +
|
||||
"bbb\n" +
|
||||
"ccccc");
|
||||
((EditorEx)myEditor).setColumnMode(false);
|
||||
mouse().pressAt(0, 0).dragTo(1, 1).release();
|
||||
copy();
|
||||
((EditorEx)myEditor).setColumnMode(true);
|
||||
mouse().clickAt(1, 0);
|
||||
paste();
|
||||
checkResultByText("a\n" +
|
||||
"a<caret>bbb\n" +
|
||||
"b<caret>ccccc");
|
||||
}
|
||||
|
||||
public void testSelectToDocumentStart() throws Exception {
|
||||
init("line1\n" +
|
||||
"line2\n" +
|
||||
|
||||
Reference in New Issue
Block a user