@@ -116,6 +116,22 @@ object Completion:
116
116
117
117
completionSymbolKind | completionKind
118
118
119
+ /** When dealing with <errors> in varios palces we check to see if they are
120
+ * due to incomplete backticks. If so, we ensure we get the full prefix
121
+ * including the backtick.
122
+ *
123
+ * @param content The source content that we'll check the positions for the prefix
124
+ * @param start The start position we'll start to look for the prefix at
125
+ * @param end The end position we'll look for the prefix at
126
+ * @return Either the full prefix including the ` or an empty string
127
+ */
128
+ private def checkBacktickPrefix (content : Array [Char ], start : Int , end : Int ): String =
129
+ content.lift(start) match
130
+ case Some (char) if char == '`' =>
131
+ content.slice(start, end).mkString
132
+ case _ =>
133
+ " "
134
+
119
135
/**
120
136
* Inspect `path` to determine the completion prefix. Only symbols whose name start with the
121
137
* returned prefix should be considered.
@@ -139,6 +155,14 @@ object Completion:
139
155
completionPrefix(selector :: Nil , pos)
140
156
.getOrElse(" " )
141
157
158
+ // Foo.`se<TAB> will result in Select(Ident(Foo), <error>)
159
+ case (select : untpd.Select ) :: _ if select.name == nme.ERROR =>
160
+ checkBacktickPrefix(select.source.content(), select.nameSpan.start, select.span.end)
161
+
162
+ // import scala.util.chaining.`s<TAB> will result in a Ident(<error>)
163
+ case (ident : untpd.Ident ) :: _ if ident.name == nme.ERROR =>
164
+ checkBacktickPrefix(ident.source.content(), ident.span.start, ident.span.end)
165
+
142
166
case (tree : untpd.RefTree ) :: _ if tree.name != nme.ERROR =>
143
167
tree.name.toString.take(pos.span.point - tree.span.point)
144
168
0 commit comments