From 6cfda948081d12eaeb4b7b6c741dab5a9c7b4ec8 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Fri, 1 Apr 2016 18:08:09 +0300 Subject: [PATCH] PY-18522 Don't paste text before the line if it's only spaces and caret is at the end of line --- .../python/editor/PythonCopyPasteProcessor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java index e4704a45158e..350639e37ce4 100644 --- a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java +++ b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java @@ -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; }