mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use the proper caret offset in case of selection. Do not overindent when replacing selection
PY-8744 Smart indent pasted lines doesn't replace selection when pasting multi-line code
This commit is contained in:
@@ -58,7 +58,7 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
final int line = document.getLineNumber(selectionModel.getSelectionStart());
|
||||
final int lineOffset = getLineStartSafeOffset(document, line);
|
||||
final PsiElement ws = file.findElementAt(lineOffset);
|
||||
int offset = ws instanceof PsiWhiteSpace? ws.getTextRange().getEndOffset() : caretOffset;
|
||||
int offset = ws instanceof PsiWhiteSpace? ws.getTextRange().getEndOffset() : selectionModel.getSelectionStart();
|
||||
if (text.equals(selectionModel.getSelectedText())) return text;
|
||||
caretModel.moveToOffset(offset);
|
||||
selectionModel.setSelection(offset, selectionModel.getSelectionEnd());
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
a = 1
|
||||
b = 1
|
||||
a = 1
|
||||
b = 1
|
||||
@@ -0,0 +1,4 @@
|
||||
a = 1
|
||||
b = 1
|
||||
<selection>c = 1
|
||||
</selection><caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
<selection>a = 1
|
||||
b = 1
|
||||
</selection><caret>c = 1
|
||||
@@ -263,6 +263,10 @@ public class PyCopyPasteTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReplaceSelection() { //PY-8744
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
String name = getTestName(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user