mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-7524 Dragged/pasted code in wrong location
fixed PY-7470 Smart copy-paste unindents next line (in place insert)
This commit is contained in:
+12
-5
@@ -108,11 +108,7 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
|
||||
final int offset = getLineStartSafeOffset(initialDocument, lineNumber);
|
||||
final int caretColumn = caretOffset - offset;
|
||||
|
||||
if (bounds.getStartOffset() != offset) { //selection
|
||||
startLine += 1;
|
||||
toIndent = Math.abs(bounds.getStartOffset() - offset);
|
||||
}
|
||||
else {
|
||||
if (bounds.getStartOffset() == offset) {
|
||||
String toString = initialDocument.getText(TextRange.create(offset, initialDocument.getLineEndOffset(lineNumber)));
|
||||
toIndent = StringUtil.findFirst(toString, new CharFilter() {
|
||||
@Override
|
||||
@@ -124,6 +120,12 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
|
||||
toIndent = caretColumn;
|
||||
}
|
||||
}
|
||||
else if (isNotApplicable(initialDocument, offset))
|
||||
return;
|
||||
else { // selection
|
||||
startLine += 1;
|
||||
toIndent = Math.abs(bounds.getStartOffset() - offset);
|
||||
}
|
||||
}
|
||||
|
||||
// actual difference in indentation level
|
||||
@@ -141,6 +143,11 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
|
||||
}
|
||||
indented.set(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private boolean isNotApplicable(DocumentImpl initialDocument, int offset) {
|
||||
return caretOffset < initialDocument.getTextLength() && !StringUtil
|
||||
.isEmptyOrSpaces(initialDocument.getText(TextRange.create(offset, caretOffset)));
|
||||
}
|
||||
});
|
||||
//System.out.println("--- after indent ---\n" + document.getText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user