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:
+2
-3
@@ -106,7 +106,6 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
|
||||
int lineNumber = initialDocument.getTextLength() > caretOffset? initialDocument.getLineNumber(caretOffset)
|
||||
: initialDocument.getLineCount() - 1;
|
||||
final int offset = getLineStartSafeOffset(initialDocument, lineNumber);
|
||||
final int caretColumn = caretOffset - offset;
|
||||
|
||||
if (bounds.getStartOffset() == offset) {
|
||||
String toString = initialDocument.getText(TextRange.create(offset, initialDocument.getLineEndOffset(lineNumber)));
|
||||
@@ -116,8 +115,8 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
|
||||
return ch != ' ';
|
||||
}
|
||||
});
|
||||
if (toIndent < 0 || toString.startsWith("\n")) {
|
||||
toIndent = caretColumn;
|
||||
if ((toIndent < 0 || toString.startsWith("\n")) && initialText.length() >= caretOffset) {
|
||||
toIndent = caretOffset - offset;
|
||||
}
|
||||
}
|
||||
else if (isNotApplicable(initialDocument, offset))
|
||||
|
||||
Reference in New Issue
Block a user