diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-06-02 20:29:58 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 20:29:58 +1000 |
commit | 473713c6210ee11f11b7ae4c83165c4f87ff2d77 (patch) | |
tree | 34d361841ded4b8f0e089615b4afa7a40e37731b /cli/tests | |
parent | 9ae8dbf17334f1cf7ae09abf585d8797f374bdc4 (diff) |
fix(#10815): lsp only responds to formatting for md, json, jsonc (#10816)
Fixes #10815
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests_lsp.rs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs index e4b963f2b..2fe984bca 100644 --- a/cli/tests/integration_tests_lsp.rs +++ b/cli/tests/integration_tests_lsp.rs @@ -2119,6 +2119,56 @@ fn lsp_format_json() { } #[test] +fn lsp_json_no_diagnostics() { + let mut client = init("initialize_params.json"); + client + .write_notification( + "textDocument/didOpen", + json!({ + "textDocument": { + "uri": "file:///a/file.json", + "languageId": "json", + "version": 1, + "text": "{\"key\":\"value\"}" + } + }), + ) + .unwrap(); + + let (maybe_res, maybe_err) = client + .write_request( + "textDocument/semanticTokens/full", + json!({ + "textDocument": { + "uri": "file:///a/file.json" + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!(maybe_res, Some(json!(null))); + + let (maybe_res, maybe_err) = client + .write_request::<_, _, Value>( + "textDocument/hover", + json!({ + "textDocument": { + "uri": "file:///a/file.json" + }, + "position": { + "line": 0, + "character": 3 + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!(maybe_res, Some(json!(null))); + + shutdown(&mut client); +} + +#[test] fn lsp_format_markdown() { let mut client = init("initialize_params.json"); client @@ -2174,6 +2224,56 @@ fn lsp_format_markdown() { } #[test] +fn lsp_markdown_no_diagnostics() { + let mut client = init("initialize_params.json"); + client + .write_notification( + "textDocument/didOpen", + json!({ + "textDocument": { + "uri": "file:///a/file.md", + "languageId": "markdown", + "version": 1, + "text": "# Hello World" + } + }), + ) + .unwrap(); + + let (maybe_res, maybe_err) = client + .write_request( + "textDocument/semanticTokens/full", + json!({ + "textDocument": { + "uri": "file:///a/file.md" + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!(maybe_res, Some(json!(null))); + + let (maybe_res, maybe_err) = client + .write_request::<_, _, Value>( + "textDocument/hover", + json!({ + "textDocument": { + "uri": "file:///a/file.md" + }, + "position": { + "line": 0, + "character": 3 + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!(maybe_res, Some(json!(null))); + + shutdown(&mut client); +} + +#[test] fn lsp_configuration_did_change() { let _g = http_server(); let mut client = init("initialize_params_did_config_change.json"); |