From b433133a1ff1c329b05ce024d8db5fefb8f7b431 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 27 Sep 2023 01:48:34 +0100 Subject: [PATCH] fix(lsp): allow query strings for "deno:/status.md" (#20697) --- cli/lsp/language_server.rs | 4 +++- cli/tests/integration/lsp_tests.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index ad0da1c576..d9db2edbf4 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -3735,7 +3735,9 @@ impl Inner { let specifier = self .url_map .normalize_url(¶ms.text_document.uri, LspUrlKind::File); - let contents = if specifier.as_str() == "deno:/status.md" { + let contents = if specifier.scheme() == "deno" + && specifier.path() == "/status.md" + { let mut contents = String::new(); let mut documents_specifiers = self .documents diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 1d0e482fa8..ca4b77f4d2 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -4320,6 +4320,35 @@ fn test_lsp_code_actions_ordering() { ); } +#[test] +fn lsp_status_file() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + + let res = client.write_request( + "deno/virtualTextDocument", + json!({ + "textDocument": { + "uri": "deno:/status.md" + } + }), + ); + let res = res.as_str().unwrap().to_string(); + assert!(res.starts_with("# Deno Language Server Status")); + + let res = client.write_request( + "deno/virtualTextDocument", + json!({ + "textDocument": { + "uri": "deno:/status.md?1" + } + }), + ); + let res = res.as_str().unwrap().to_string(); + assert!(res.starts_with("# Deno Language Server Status")); +} + #[test] fn lsp_code_actions_deno_cache() { let context = TestContextBuilder::new().use_temp_cwd().build();