From 021aa0b36b1ac4484406df8dc627eeceab5a6eba Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Mon, 15 May 2017 18:23:48 +0300 Subject: [PATCH] Don't show completion autopopup after Python int literals (PY-24242) After changes introduced in IDEA-123325 the IntelliJ platform started to show completion autopopup on typing digits in addition to letters. --- .../codeInsight/completion/PyCompletionConfidence.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/completion/PyCompletionConfidence.java b/python/src/com/jetbrains/python/codeInsight/completion/PyCompletionConfidence.java index 7787b003eac1..23ebfc1f6fb9 100644 --- a/python/src/com/jetbrains/python/codeInsight/completion/PyCompletionConfidence.java +++ b/python/src/com/jetbrains/python/codeInsight/completion/PyCompletionConfidence.java @@ -16,11 +16,11 @@ package com.jetbrains.python.codeInsight.completion; import com.intellij.codeInsight.completion.CompletionConfidence; -import com.intellij.codeInsight.completion.CompletionParameters; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.tree.IElementType; import com.intellij.util.ThreeState; import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.psi.PyStringLiteralExpression; @@ -38,10 +38,11 @@ public class PyCompletionConfidence extends CompletionConfidence { public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) { ASTNode node = contextElement.getNode(); if (node != null) { - if (node.getElementType() == PyTokenTypes.FLOAT_LITERAL) { + final IElementType elementType = node.getElementType(); + if (elementType == PyTokenTypes.FLOAT_LITERAL || elementType == PyTokenTypes.INTEGER_LITERAL) { return ThreeState.YES; } - if (PyTokenTypes.STRING_NODES.contains(node.getElementType())) { + if (PyTokenTypes.STRING_NODES.contains(elementType)) { final PsiElement parent = contextElement.getParent(); if (parent instanceof PyStringLiteralExpression) { final List ranges = ((PyStringLiteralExpression)parent).getStringValueTextRanges();