File tree 1 file changed +39
-1
lines changed
crates/rust-analyzer/src/lsp
1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -1705,9 +1705,10 @@ fn bar(_: usize) {}
1705
1705
expect : Expect ,
1706
1706
) {
1707
1707
let source = stdx:: trim_indent ( ra_fixture) ;
1708
+ let endings = if source. contains ( '\r' ) { LineEndings :: Dos } else { LineEndings :: Unix } ;
1708
1709
let line_index = LineIndex {
1709
1710
index : Arc :: new ( ide:: LineIndex :: new ( & source) ) ,
1710
- endings : LineEndings :: Unix ,
1711
+ endings,
1711
1712
encoding : PositionEncoding :: Utf8 ,
1712
1713
} ;
1713
1714
@@ -2609,6 +2610,43 @@ struct ProcMacro {
2609
2610
) ;
2610
2611
}
2611
2612
2613
+ #[ test]
2614
+ fn snippet_rendering_handle_dos_line_endings ( ) {
2615
+ // unix -> dos conversion should be handled after placing snippets
2616
+ let mut edit = TextEdit :: builder ( ) ;
2617
+ edit. insert ( 6 . into ( ) , "\n \n ->" . to_owned ( ) ) ;
2618
+
2619
+ let edit = edit. finish ( ) ;
2620
+ let snippets = SnippetEdit :: new ( vec ! [ Snippet :: Tabstop ( 10 . into( ) ) ] ) ;
2621
+
2622
+ check_rendered_snippets_in_source (
2623
+ "yeah\r \n <-tabstop here" ,
2624
+ edit,
2625
+ snippets,
2626
+ expect ! [ [ r#"
2627
+ [
2628
+ SnippetTextEdit {
2629
+ range: Range {
2630
+ start: Position {
2631
+ line: 1,
2632
+ character: 0,
2633
+ },
2634
+ end: Position {
2635
+ line: 1,
2636
+ character: 0,
2637
+ },
2638
+ },
2639
+ new_text: "\r\n\r\n->$0",
2640
+ insert_text_format: Some(
2641
+ Snippet,
2642
+ ),
2643
+ annotation_id: None,
2644
+ },
2645
+ ]
2646
+ "# ] ] ,
2647
+ )
2648
+ }
2649
+
2612
2650
// `Url` is not able to parse windows paths on unix machines.
2613
2651
#[ test]
2614
2652
#[ cfg( target_os = "windows" ) ]
You can’t perform that action at this time.
0 commit comments