mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-54362 When "Insert pair bracket" on Editor->Smart keys page is off, IDEA still inserts both parentheses on autocomplete lookup, but overtype doesn't work for functions with at least one argument
This commit is contained in:
@@ -930,7 +930,7 @@ public class JavaCompletionUtil {
|
||||
|
||||
|
||||
final boolean needLeftParenth = isToInsertParenth(file.findElementAt(context.getStartOffset()));
|
||||
final boolean needRightParenth = shouldInsertRParenth(context.getCompletionChar(), tailType, hasParams);
|
||||
final boolean needRightParenth = tailType != TailType.SMART_COMPLETION && CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET;
|
||||
|
||||
if (needLeftParenth) {
|
||||
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(context.getProject());
|
||||
@@ -948,6 +948,10 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
|
||||
if (tailType == TailType.SEMICOLON) {
|
||||
if (!needRightParenth) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
|
||||
if (psiElement().beforeLeaf(psiElement().withText(".")).accepts(file.findElementAt(context.getTailOffset() - 1))) {
|
||||
return;
|
||||
@@ -959,19 +963,6 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldInsertRParenth(char completionChar, TailType tailType, boolean hasParams) {
|
||||
if (tailType == TailType.SMART_COMPLETION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completionChar == '(' && !hasParams) {
|
||||
//it's highly probable that the user will type ')' next and it may not be overwritten if the flag is off
|
||||
return CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TailType getTailType(final LookupElement item, InsertionContext context) {
|
||||
final char completionChar = context.getCompletionChar();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class MyClass {
|
||||
|
||||
void foo() {}
|
||||
|
||||
{
|
||||
fo<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class MyClass {
|
||||
|
||||
void foo() {}
|
||||
|
||||
{
|
||||
foo(<caret>
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@ class MyClass {
|
||||
void foo() {}
|
||||
|
||||
{
|
||||
foo();<caret>
|
||||
foo(<caret>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user