Skip to content

Commit 8eb5f46

Browse files
ampleyflyignatov
authored andcommitted
Quote record field completions if necessary
1 parent 429894e commit 8eb5f46

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/org/intellij/erlang/completion/ErlangCompletionContributor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull
246246
}
247247

248248
private static LookupElement createFieldLookupElement(@NotNull Project project, @NotNull String text, boolean withoutEq) {
249-
return LookupElementBuilder.create(text)
249+
String maybeQuotedText = ErlangPsiImplUtil.needQuotation(text)
250+
? "'" + text + "'"
251+
: text;
252+
return LookupElementBuilder.create(maybeQuotedText)
250253
.withIcon(ErlangIcons.FIELD)
251254
.withInsertHandler(withoutEq ? null : equalsInsertHandler(project));
252255
}

tests/org/intellij/erlang/completion/ErlangCompletionTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ public void testRecordFields6() {
9191
"bar(A, B)-> A#foo{two = }");
9292
}
9393

94+
public void testRecordFields7() {
95+
doTestInclude(
96+
"-record(foo, {id, 'WeirdCase', 'strange-symbol'}).\n" +
97+
"bar(A, B)-> A#foo{<caret>}",
98+
"id", "'WeirdCase'", "'strange-symbol'");
99+
}
100+
94101
public void testMacros() {
95102
doTestInclude(
96103
"-define(foo, 1).\n" +

0 commit comments

Comments
 (0)