From c08391ce32c471d09fcc6fe48bd295bbb5a7de10 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Fri, 8 Jan 2021 17:49:13 +0800 Subject: support folder rename for initial request. --- crates/rust-analyzer/src/caps.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 80e46bf7f..5167a005f 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -77,14 +77,22 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti will_create: None, did_rename: None, will_rename: Some(FileOperationRegistrationOptions { - filters: vec![FileOperationFilter { - scheme: Some(String::from("file")), - pattern: FileOperationPattern { - glob: String::from("**/*.rs"), - matches: Some(FileOperationPatternKind::File), - options: None, - }, - }], + filters: vec![ + FileOperationFilter { + scheme: Some(String::from("file")), + pattern: FileOperationPattern { + glob: String::from("**/*.rs"), + matches: Some(FileOperationPatternKind::File), + options: None, + }, + FileOperationFilter { + scheme: Some(String::from("untitled")), + pattern: FileOperationPattern { + glob: String::from("**"), + matches: Some(FileOperationPatternKind::Folder), + options: None, + }, + }], }), did_delete: None, will_delete: None, -- cgit v1.2.3 From 0d86e222297233387ad4abc2796dfd27c5333aaa Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Sun, 10 Jan 2021 01:29:08 +0800 Subject: beta version for folder rename --- crates/rust-analyzer/src/caps.rs | 3 ++- crates/rust-analyzer/src/handlers.rs | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 5167a005f..406a93b10 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -85,8 +85,9 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti matches: Some(FileOperationPatternKind::File), options: None, }, + }, FileOperationFilter { - scheme: Some(String::from("untitled")), + scheme: Some(String::from("file")), pattern: FileOperationPattern { glob: String::from("**"), matches: Some(FileOperationPatternKind::Folder), diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c13cdc4e3..176774a77 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -432,9 +432,26 @@ pub(crate) fn handle_will_rename_files( // Limit to single-level moves for now. match (from_path.parent(), to_path.parent()) { (Some(p1), Some(p2)) if p1 == p2 => { - let new_name = to_path.file_stem()?; - let new_name = new_name.to_str()?; - Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) + if from_path.is_dir() { + // This is a quick implement, try to use will_rename_file code. + // imitate change the older_folder/mod.rs to older_folder/new_folder.rs + let imitate_from_path = from_path.join("mod.rs"); + let new_from_url = imitate_from_path.to_str()?; + let new_from_url = Url::parse(new_from_url).ok()?; + + let new_folder_name = to_path.file_name()?.to_str()?; + let mut imite_new_file_name = new_folder_name.to_string(); + imite_new_file_name.push_str(".rs"); + let new_to = from_path.join(imite_new_file_name); + let new_to = new_to.to_str()?; + + Some((snap.url_to_file_id(&new_from_url).ok()?, new_to.to_string())) + } + else{ + let new_name = to_path.file_stem()?; + let new_name = new_name.to_str()?; + Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) + } } _ => None, } -- cgit v1.2.3 From 09ed9d044495971c143dc8c9879dd92d3989976f Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Sun, 10 Jan 2021 14:10:36 +0800 Subject: fix issue. --- crates/rust-analyzer/src/handlers.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 176774a77..480608196 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -435,22 +435,22 @@ pub(crate) fn handle_will_rename_files( if from_path.is_dir() { // This is a quick implement, try to use will_rename_file code. // imitate change the older_folder/mod.rs to older_folder/new_folder.rs - let imitate_from_path = from_path.join("mod.rs"); - let new_from_url = imitate_from_path.to_str()?; - let new_from_url = Url::parse(new_from_url).ok()?; - - let new_folder_name = to_path.file_name()?.to_str()?; - let mut imite_new_file_name = new_folder_name.to_string(); - imite_new_file_name.push_str(".rs"); - let new_to = from_path.join(imite_new_file_name); - let new_to = new_to.to_str()?; - - Some((snap.url_to_file_id(&new_from_url).ok()?, new_to.to_string())) - } - else{ + let imitate_from_url = from.join("mod.rs").ok()?; + let imite_new_file_name = to_path.file_name()?.to_str()?; + Some(( + snap.url_to_file_id(&imitate_from_url).ok()?, + imite_new_file_name.to_string(), + )) + } else { + let old_name = from_path.file_stem()?; + let old_name = old_name.to_str()?; let new_name = to_path.file_stem()?; let new_name = new_name.to_str()?; - Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) + if old_name != "mod" || new_name != "mod" { + Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) + } else { + None + } } } _ => None, -- cgit v1.2.3 From b0e300c793db1110266056ac4b7fdfea10c3bba0 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Sun, 10 Jan 2021 14:27:18 +0800 Subject: fix condition. --- crates/rust-analyzer/src/handlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 480608196..1aafef78b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -446,7 +446,7 @@ pub(crate) fn handle_will_rename_files( let old_name = old_name.to_str()?; let new_name = to_path.file_stem()?; let new_name = new_name.to_str()?; - if old_name != "mod" || new_name != "mod" { + if old_name != "mod" && new_name != "mod" { Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) } else { None -- cgit v1.2.3 From b9d52444cf621e474e0117e70c335dde2cbf3515 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Sun, 10 Jan 2021 14:39:44 +0800 Subject: update rs format --- crates/rust-analyzer/src/caps.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 406a93b10..076e191d9 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -93,7 +93,8 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti matches: Some(FileOperationPatternKind::Folder), options: None, }, - }], + }, + ], }), did_delete: None, will_delete: None, -- cgit v1.2.3 From f7cb9e9fbe50e5d0e23e81b8b5b90405ef5c1931 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Mon, 11 Jan 2021 14:45:35 +0800 Subject: move logic from client to server. --- crates/rust-analyzer/src/handlers.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 1aafef78b..17f67d4b7 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -435,7 +435,15 @@ pub(crate) fn handle_will_rename_files( if from_path.is_dir() { // This is a quick implement, try to use will_rename_file code. // imitate change the older_folder/mod.rs to older_folder/new_folder.rs - let imitate_from_url = from.join("mod.rs").ok()?; + + // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` + let old_folder_name = from_path.file_stem()?; + let old_folder_name = old_folder_name.to_str()?; + let mut old_folder_name = old_folder_name.to_string(); + old_folder_name.push('/'); + let from_with_trailing_slash = from.join(&old_folder_name).ok()?; + + let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?; let imite_new_file_name = to_path.file_name()?.to_str()?; Some(( snap.url_to_file_id(&imitate_from_url).ok()?, -- cgit v1.2.3 From 497e9da43361daabfd0cf3653181be86b4163bce Mon Sep 17 00:00:00 2001 From: Song Gao <158983297@qq.com> Date: Tue, 12 Jan 2021 00:15:56 +0800 Subject: Update crates/rust-analyzer/src/handlers.rs Co-authored-by: Jeremy Kolb --- crates/rust-analyzer/src/handlers.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 17f67d4b7..c1e34c54d 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -450,10 +450,8 @@ pub(crate) fn handle_will_rename_files( imite_new_file_name.to_string(), )) } else { - let old_name = from_path.file_stem()?; - let old_name = old_name.to_str()?; - let new_name = to_path.file_stem()?; - let new_name = new_name.to_str()?; + let old_name = from_path.file_stem()?.to_str()?; + let new_name = to_path.file_stem()?.to_str()?; if old_name != "mod" && new_name != "mod" { Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) } else { -- cgit v1.2.3 From 1b004dcf8826b0bc73b69b69683e9bf7d996829b Mon Sep 17 00:00:00 2001 From: Song Gao <158983297@qq.com> Date: Tue, 12 Jan 2021 00:16:12 +0800 Subject: Update crates/rust-analyzer/src/handlers.rs Co-authored-by: Jeremy Kolb --- crates/rust-analyzer/src/handlers.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c1e34c54d..c7b615002 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -437,9 +437,7 @@ pub(crate) fn handle_will_rename_files( // imitate change the older_folder/mod.rs to older_folder/new_folder.rs // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` - let old_folder_name = from_path.file_stem()?; - let old_folder_name = old_folder_name.to_str()?; - let mut old_folder_name = old_folder_name.to_string(); + let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string(); old_folder_name.push('/'); let from_with_trailing_slash = from.join(&old_folder_name).ok()?; -- cgit v1.2.3 From d8773908821a17ba160eaccab45b6813048b1abf Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Tue, 12 Jan 2021 00:21:03 +0800 Subject: fix as suggestion. --- crates/rust-analyzer/src/handlers.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c7b615002..1f21533cb 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -433,27 +433,23 @@ pub(crate) fn handle_will_rename_files( match (from_path.parent(), to_path.parent()) { (Some(p1), Some(p2)) if p1 == p2 => { if from_path.is_dir() { - // This is a quick implement, try to use will_rename_file code. - // imitate change the older_folder/mod.rs to older_folder/new_folder.rs - // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string(); old_folder_name.push('/'); let from_with_trailing_slash = from.join(&old_folder_name).ok()?; let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?; - let imite_new_file_name = to_path.file_name()?.to_str()?; + let new_file_name = to_path.file_name()?.to_str()?; Some(( snap.url_to_file_id(&imitate_from_url).ok()?, - imite_new_file_name.to_string(), + new_file_name.to_string(), )) } else { let old_name = from_path.file_stem()?.to_str()?; let new_name = to_path.file_stem()?.to_str()?; - if old_name != "mod" && new_name != "mod" { - Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) - } else { - None + match(old_name,new_name){ + ("mod","mod") =>Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())), + _=>None } } } -- cgit v1.2.3 From cf3042f8818deb67636507241e853ffb6ab2daf3 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Tue, 12 Jan 2021 00:21:43 +0800 Subject: format --- crates/rust-analyzer/src/handlers.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 1f21533cb..53e64f106 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -447,9 +447,11 @@ pub(crate) fn handle_will_rename_files( } else { let old_name = from_path.file_stem()?.to_str()?; let new_name = to_path.file_stem()?.to_str()?; - match(old_name,new_name){ - ("mod","mod") =>Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())), - _=>None + match (old_name, new_name) { + ("mod", "mod") => { + Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) + } + _ => None, } } } -- cgit v1.2.3 From e1c9c9b6049d9610d2e4454ffb7c337cb5c69d5b Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Wed, 13 Jan 2021 00:30:49 +0800 Subject: fix and add tests. --- crates/rust-analyzer/src/handlers.rs | 7 +- crates/rust-analyzer/tests/rust-analyzer/main.rs | 143 ++++++++++++++++++++++- 2 files changed, 142 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 53e64f106..bfd92159c 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -448,10 +448,9 @@ pub(crate) fn handle_will_rename_files( let old_name = from_path.file_stem()?.to_str()?; let new_name = to_path.file_stem()?.to_str()?; match (old_name, new_name) { - ("mod", "mod") => { - Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) - } - _ => None, + ("mod", _) => None, + (_, "mod") => None, + _ => Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())), } } } diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 84db0856d..787239385 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -15,11 +15,14 @@ use std::{collections::HashMap, path::PathBuf, time::Instant}; use lsp_types::{ notification::DidOpenTextDocument, - request::{CodeActionRequest, Completion, Formatting, GotoTypeDefinition, HoverRequest}, + request::{ + CodeActionRequest, Completion, Formatting, GotoTypeDefinition, HoverRequest, + WillRenameFiles, + }, CodeActionContext, CodeActionParams, CompletionParams, DidOpenTextDocumentParams, - DocumentFormattingParams, FormattingOptions, GotoDefinitionParams, HoverParams, - PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, - WorkDoneProgressParams, + DocumentFormattingParams, FileRename, FormattingOptions, GotoDefinitionParams, HoverParams, + PartialResultParams, Position, Range, RenameFilesParams, TextDocumentItem, + TextDocumentPositionParams, WorkDoneProgressParams, }; use rust_analyzer::lsp_ext::{OnEnter, Runnables, RunnablesParams}; use serde_json::json; @@ -733,3 +736,135 @@ pub fn foo(_input: TokenStream) -> TokenStream { let value = res.get("contents").unwrap().get("value").unwrap().to_string(); assert_eq!(value, r#""\n```rust\nfoo::Bar\n```\n\n```rust\nfn bar()\n```""#) } + +#[test] +fn test_will_rename_files_same_level() { + // if skip_slow_tests() { + // return; + // } + let tmp_dir = TestDir::new(); + let tmp_dir_path = tmp_dir.path().to_owned(); + let tmp_dir_path = tmp_dir_path.to_str().unwrap(); + let base_path = PathBuf::from(format!("file://{}", tmp_dir_path)); + + let code = r#" +//- /Cargo.toml +[package] +name = "foo" +version = "0.0.0" + +//- /src/lib.rs +mod old_file; +mod from_mod; +mod to_mod; +mod old_folder; +fn main() {} + +//- /src/old_file.rs + +//- /src/old_folder/mod.rs + +//- /src/from_mod/mod.rs + +//- /src/to_mod/foo.rs + +"#; + let server = + Project::with_fixture(&code).tmp_dir(tmp_dir).server().wait_until_workspace_is_loaded(); + + //rename same level file + server.request::( + RenameFilesParams { + files: vec![FileRename { + old_uri: base_path.join("src/old_file.rs").to_str().unwrap().to_string(), + new_uri: base_path.join("src/new_file.rs").to_str().unwrap().to_string(), + }], + }, + json!({ + "documentChanges": [ + { + "textDocument": { + "uri": format!("file://{}/src/lib.rs", tmp_dir_path), + "version": null + }, + "edits": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 12 + } + }, + "newText": "new_file" + } + ] + } + ] + }), + ); + + //rename file from mod.rs to foo.rs + server.request::( + RenameFilesParams { + files: vec![FileRename { + old_uri: base_path.join("src/from_mod/mod.rs").to_str().unwrap().to_string(), + new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), + }], + }, + json!({ + "documentChanges": [] + }), + ); + + //rename file from foo.rs to mod.rs + server.request::( + RenameFilesParams { + files: vec![FileRename { + old_uri: base_path.join("src/to_mod/foo.rs").to_str().unwrap().to_string(), + new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), + }], + }, + json!({ + "documentChanges": [] + }), + ); + + //rename same level file + server.request::( + RenameFilesParams { + files: vec![FileRename { + old_uri: base_path.join("src/old_folder").to_str().unwrap().to_string(), + new_uri: base_path.join("src/new_folder").to_str().unwrap().to_string(), + }], + }, + json!({ + "documentChanges": [ + { + "textDocument": { + "uri": format!("file://{}/src/lib.rs", tmp_dir_path), + "version": null + }, + "edits": [ + { + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 14 + } + }, + "newText": "new_folder" + } + ] + } + ] + }), + ); +} -- cgit v1.2.3 From 5f8fa66b77d33b6adfcfa20d138f9dd3a8de35b4 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Wed, 13 Jan 2021 00:53:17 +0800 Subject: use path rather than hard code. --- crates/rust-analyzer/tests/rust-analyzer/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 787239385..97f06d94c 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -744,8 +744,8 @@ fn test_will_rename_files_same_level() { // } let tmp_dir = TestDir::new(); let tmp_dir_path = tmp_dir.path().to_owned(); - let tmp_dir_path = tmp_dir_path.to_str().unwrap(); - let base_path = PathBuf::from(format!("file://{}", tmp_dir_path)); + let tmp_dir_str = tmp_dir_path.to_str().unwrap(); + let base_path = PathBuf::from(format!("file://{}", tmp_dir_str)); let code = r#" //- /Cargo.toml @@ -784,7 +784,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}/src/lib.rs", tmp_dir_path), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs")), "version": null }, "edits": [ @@ -845,7 +845,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}/src/lib.rs", tmp_dir_path), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs")), "version": null }, "edits": [ -- cgit v1.2.3 From 6a15876fc4127f0fb912385917054dbf478416e6 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Wed, 13 Jan 2021 00:58:28 +0800 Subject: skip slow tests. --- crates/rust-analyzer/tests/rust-analyzer/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 97f06d94c..91e502d8a 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -739,9 +739,10 @@ pub fn foo(_input: TokenStream) -> TokenStream { #[test] fn test_will_rename_files_same_level() { - // if skip_slow_tests() { - // return; - // } + if skip_slow_tests() { + return; + } + let tmp_dir = TestDir::new(); let tmp_dir_path = tmp_dir.path().to_owned(); let tmp_dir_str = tmp_dir_path.to_str().unwrap(); -- cgit v1.2.3 From 76e65890163c9d6a4105e6c52143ae81f805ba82 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Wed, 13 Jan 2021 12:10:45 +0800 Subject: unwrap. --- crates/rust-analyzer/tests/rust-analyzer/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 91e502d8a..c4554e9d3 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -785,7 +785,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs")), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap()), "version": null }, "edits": [ @@ -846,7 +846,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs")), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap()), "version": null }, "edits": [ -- cgit v1.2.3 From 727a7827fd992e86a4c1fe547f27d2fa299d3099 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Wed, 13 Jan 2021 22:56:31 +0800 Subject: fix windows test. --- crates/rust-analyzer/tests/rust-analyzer/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index c4554e9d3..3d99c1f52 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -785,7 +785,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap()), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace("\\", "/")), "version": null }, "edits": [ @@ -846,7 +846,7 @@ fn main() {} "documentChanges": [ { "textDocument": { - "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap()), + "uri": format!("file://{}", tmp_dir_path.join("src").join("lib.rs").to_str().unwrap().to_string().replace("C:\\", "/c:/").replace("\\", "/")), "version": null }, "edits": [ -- cgit v1.2.3