diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/lsp_tests.rs | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 62cb84457..944285293 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -9765,13 +9765,13 @@ fn lsp_format_json() { let res = client.write_request( "textDocument/formatting", json!({ - "textDocument": { - "uri": json_file.uri(), - }, - "options": { - "tabSize": 2, - "insertSpaces": true - } + "textDocument": { + "uri": json_file.uri(), + }, + "options": { + "tabSize": 2, + "insertSpaces": true + } }), ); @@ -9803,6 +9803,67 @@ fn lsp_format_json() { } #[test] +fn lsp_format_editor_options() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + let file = source_file( + temp_dir.path().join("file.ts"), + "if (true) {\n console.log();\n}\n", + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + let res = client.write_request( + "textDocument/formatting", + json!({ + "textDocument": { + "uri": file.uri(), + }, + "options": { + "tabSize": 4, + "insertSpaces": true, + }, + }), + ); + assert_eq!( + res, + json!([ + { + "range": { + "start": { "line": 1, "character": 0 }, + "end": { "line": 1, "character": 0 }, + }, + "newText": " ", + }, + ]) + ); + let res = client.write_request( + "textDocument/formatting", + json!({ + "textDocument": { + "uri": file.uri(), + }, + "options": { + "tabSize": 2, + "insertSpaces": false, + }, + }), + ); + assert_eq!( + res, + json!([ + { + "range": { + "start": { "line": 1, "character": 0 }, + "end": { "line": 1, "character": 2 }, + }, + "newText": "\t", + }, + ]) + ); + client.shutdown(); +} + +#[test] fn lsp_json_no_diagnostics() { let context = TestContextBuilder::new().use_temp_cwd().build(); let mut client = context.new_lsp_command().build(); @@ -9964,7 +10025,7 @@ fn lsp_format_with_config() { }, "options": { "tabSize": 2, - "insertSpaces": true + "insertSpaces": false } }), ); |