From de3f2948ea2416d65640c07d2c69df75a4273d50 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:26:07 +0300 Subject: add tests for crlf --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crates/ra_lsp_server/tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index de3bd5bc5..ec075a2fd 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -414,3 +414,49 @@ fn main() {{}} let elapsed = start.elapsed(); assert!(elapsed.as_millis() < 2000, "typing enter took {:?}", elapsed); } + +#[test] +fn preserves_dos_line_endings() { + let server = Project::with_fixture( + &r#" +//- Cargo.toml +[package] +name = "foo" +version = "0.0.0" + +//- src/main.rs +/// Some Docs\r\nfn main() {} +"#, + ) + .server(); + + server.request::( + TextDocumentPositionParams { + text_document: server.doc_id("src/main.rs"), + position: Position { line: 0, character: 8 }, + }, + json!({ + "cursorPosition": { + "position": { "line": 1, "character": 4 }, + "textDocument": { "uri": "file:///[..]src/main.rs" } + }, + "label": "on enter", + "workspaceEdit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "\r\n/// ", + "range": { + "end": { "line": 0, "character": 8 }, + "start": { "line": 0, "character": 8 } + } + } + ], + "textDocument": { "uri": "file:///[..]src/main.rs", "version": null } + } + ] + } + }), + ); +} -- cgit v1.2.3 From 6ea4184fd107e5cc155b95a3cf058200c38d544d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:53:59 +0300 Subject: translate \n -> \r\n on the way out --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_lsp_server/tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index ec075a2fd..152681062 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -208,7 +208,7 @@ pub use std::collections::HashMap; "range": { "end": { "character": 0, - "line": 6 + "line": 7 }, "start": { "character": 0, @@ -418,15 +418,15 @@ fn main() {{}} #[test] fn preserves_dos_line_endings() { let server = Project::with_fixture( - &r#" + &" //- Cargo.toml [package] -name = "foo" -version = "0.0.0" +name = \"foo\" +version = \"0.0.0\" //- src/main.rs /// Some Docs\r\nfn main() {} -"#, +", ) .server(); -- cgit v1.2.3