diff --git a/tests/tests.rs b/tests/tests.rs index 50f3303c4ca..4c13f6d006b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1364,3 +1364,75 @@ fn cmd_lens_run() { rls.shutdown(rls_timeout()); } + +#[test] +fn test_def_static_method_call() { + let p = project("simple_workspace") + .file("Cargo.toml", &basic_bin_manifest("bar")) + .file( + "src/main.rs", + r#" + struct Foo { + } + + impl Foo { + fn new() { + } + } + + fn main() { + Foo::new(); + } + "#, + ) + .build(); + + let root_path = p.root(); + let mut rls = p.spawn_rls(); + + rls.request( + 0, + "initialize", + Some(json!({ + "rootPath": root_path, + "capabilities": {} + })), + ) + .unwrap(); + + let request_id = 1; + + rls.request( + request_id, + "textDocument/definition", + Some(json!({ + "position": { + "character": 20, // Foo + "line": 10 + }, + "textDocument": { + "uri": format!("file://{}/src/main.rs", root_path.display()), + "version": 1 + } + })), + ) + .unwrap(); + + let json = rls.wait_until_json_id(request_id, rls_timeout()); + let result = json["result"].as_array().unwrap(); + assert_eq!( + result[0]["range"], + json!({ + "start": { + "line": 1, + "character": 23, + }, + "end": { + "line": 1, + "character": 23, + } + }) + ); + + rls.shutdown(rls_timeout()); +}