@@ -15,7 +15,6 @@ import dotty.tools.dotc.core.StdNames.nme
15
15
import dotty .tools .dotc .core .SymDenotations .SymDenotation
16
16
import dotty .tools .dotc .core .TypeError
17
17
import dotty .tools .dotc .core .Types .{ExprType , MethodOrPoly , NameFilter , NoType , TermRef , Type }
18
- import dotty .tools .dotc .parsing .Scanners
19
18
import dotty .tools .dotc .parsing .Tokens
20
19
import dotty .tools .dotc .util .Chars
21
20
import dotty .tools .dotc .util .SourcePosition
@@ -118,6 +117,7 @@ object Completion {
118
117
private def computeCompletions (pos : SourcePosition , path : List [Tree ])(using Context ): (Int , List [Completion ]) = {
119
118
val mode = completionMode(path, pos)
120
119
val rawPrefix = completionPrefix(path, pos)
120
+
121
121
val hasBackTick = rawPrefix.headOption.contains('`' )
122
122
val prefix = if hasBackTick then rawPrefix.drop(1 ) else rawPrefix
123
123
@@ -135,7 +135,8 @@ object Completion {
135
135
}
136
136
137
137
val describedCompletions = describeCompletions(completions)
138
- val backtickedCompletions = describedCompletions.map(backtickCompletions)
138
+ val backtickedCompletions =
139
+ describedCompletions.map(completion => backtickCompletions(completion, hasBackTick))
139
140
140
141
val offset = completionOffset(path)
141
142
@@ -147,14 +148,14 @@ object Completion {
147
148
(offset, backtickedCompletions)
148
149
}
149
150
150
- def backtickCompletions (completion : Completion ) =
151
- if needsBacktick(completion.label) then
151
+ def backtickCompletions (completion : Completion , hasBackTick : Boolean ) =
152
+ if hasBackTick || needsBacktick(completion.label) then
152
153
completion.copy(label = s " ` ${completion.label}` " )
153
154
else
154
155
completion
155
156
156
157
// This borrows from Metals, which itself borrows from Ammonite. This uses
157
- // the same apprach , but some of the utils that already exist in Dotty.
158
+ // the same approach , but some of the utils that already exist in Dotty.
158
159
// https://github.com/scalameta/metals/blob/main/mtags/src/main/scala/scala/meta/internal/mtags/KeywordWrapper.scala
159
160
// https://github.com/com-lihaoyi/Ammonite/blob/73a874173cd337f953a3edc9fb8cb96556638fdd/amm/util/src/main/scala/ammonite/util/Model.scala
160
161
private def needsBacktick (s : String ) =
@@ -429,6 +430,7 @@ object Completion {
429
430
private def include (denot : SingleDenotation , nameInScope : Name )(using Context ): Boolean =
430
431
val sym = denot.symbol
431
432
433
+
432
434
nameInScope.startsWith(prefix) &&
433
435
sym.exists &&
434
436
completionsFilter(NoType , nameInScope) &&
0 commit comments