PY-18522 Don't paste text before the line if it's only spaces and caret is at the end of line

This commit is contained in:
Mikhail Golubev
2016-04-04 12:51:13 +03:00
parent c6a6bac3e8
commit 6cfda94808
@@ -186,13 +186,15 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
}
private static boolean isApplicable(@NotNull final PsiFile file, @NotNull String text, int caretOffset) {
final boolean useTabs =
CodeStyleSettingsManager.getSettings(file.getProject()).useTabCharacter(PythonFileType.INSTANCE);
final boolean useTabs = CodeStyleSettingsManager.getSettings(file.getProject()).useTabCharacter(PythonFileType.INSTANCE);
final PsiElement nonWS = PyUtil.findNextAtOffset(file, caretOffset, PsiWhiteSpace.class);
if (nonWS == null || text.endsWith("\n"))
return true;
if (inStatementList(file, caretOffset) && (text.startsWith(useTabs ? "\t" : " ") || StringUtil.split(text, "\n").size() > 1))
if (nonWS == null) {
return !StringUtil.isEmptyOrSpaces(text);
}
if (text.endsWith("\n") ||
(inStatementList(file, caretOffset) && (text.startsWith(useTabs ? "\t" : " ") || StringUtil.split(text, "\n").size() > 1))) {
return true;
}
return false;
}