@@ -258,7 +258,7 @@ pub(crate) fn complete_postfix(
258
258
}
259
259
260
260
fn get_receiver_text ( receiver : & ast:: Expr , receiver_is_ambiguous_float_literal : bool ) -> String {
261
- let text = if receiver_is_ambiguous_float_literal {
261
+ let mut text = if receiver_is_ambiguous_float_literal {
262
262
let text = receiver. syntax ( ) . text ( ) ;
263
263
let without_dot = ..text. len ( ) - TextSize :: of ( '.' ) ;
264
264
text. slice ( without_dot) . to_string ( )
@@ -267,12 +267,18 @@ fn get_receiver_text(receiver: &ast::Expr, receiver_is_ambiguous_float_literal:
267
267
} ;
268
268
269
269
// The receiver texts should be interpreted as-is, as they are expected to be
270
- // normal Rust expressions. We escape '\' and '$' so they don't get treated as
271
- // snippet-specific constructs.
272
- //
273
- // Note that we don't need to escape the other characters that can be escaped,
274
- // because they wouldn't be treated as snippet-specific constructs without '$'.
275
- text. replace ( '\\' , "\\ \\ " ) . replace ( '$' , "\\ $" )
270
+ // normal Rust expressions.
271
+ escape_snippet_bits ( & mut text) ;
272
+ text
273
+ }
274
+
275
+ /// Escapes `\` and `$` so that they don't get interpreted as snippet-specific constructs.
276
+ ///
277
+ /// Note that we don't need to escape the other characters that can be escaped,
278
+ /// because they wouldn't be treated as snippet-specific constructs without '$'.
279
+ fn escape_snippet_bits ( text : & mut String ) {
280
+ stdx:: replace ( text, '\\' , "\\ \\ " ) ;
281
+ stdx:: replace ( text, '$' , "\\ $" ) ;
276
282
}
277
283
278
284
fn include_references ( initial_element : & ast:: Expr ) -> ( ast:: Expr , ast:: Expr ) {
0 commit comments