PY-12932 Fix trailing comment detection when it's the first child element

This commit is contained in:
Mikhail Golubev
2015-02-09 21:43:37 +03:00
parent d46f76eda1
commit 4ca4d0d396
3 changed files with 3 additions and 1 deletions
@@ -132,6 +132,6 @@ public class PyPreFormatProcessor implements PreFormatProcessor {
private static boolean isTrailingComment(@NotNull PsiComment comment) {
final PsiElement prevElement = comment.getPrevSibling();
return !(prevElement instanceof PsiWhiteSpace) || !prevElement.textContains('\n');
return prevElement != null && (!(prevElement instanceof PsiWhiteSpace) || !prevElement.textContains('\n'));
}
}
@@ -1,3 +1,4 @@
# This normal comment won't be touched as well
# for a in [1, 2, 3]:
# if a == 1:
# print 'x'
@@ -1,3 +1,4 @@
# This normal comment won't be touched as well
# for a in [1, 2, 3]:
# if a == 1:
# print 'x'