|
7 | 7 |
|
8 | 8 | use lsp_server::RequestId; |
9 | 9 | use lsp_server::Response; |
| 10 | +use lsp_types::Url; |
10 | 11 |
|
11 | 12 | use crate::test::lsp::lsp_interaction::object_model::InitializeSettings; |
12 | 13 | use crate::test::lsp::lsp_interaction::object_model::LspInteraction; |
@@ -163,3 +164,76 @@ fn test_error_documentation_links() { |
163 | 164 |
|
164 | 165 | interaction.shutdown(); |
165 | 166 | } |
| 167 | + |
| 168 | +#[test] |
| 169 | +fn test_version_support_publish_diagnostics() { |
| 170 | + let test_files_root = get_test_files_root(); |
| 171 | + let root = test_files_root.path().to_path_buf(); |
| 172 | + let mut file = root.clone(); |
| 173 | + file.push("text_document.py"); |
| 174 | + let uri = Url::from_file_path(file).unwrap(); |
| 175 | + let mut interaction = LspInteraction::new(); |
| 176 | + interaction.set_root(root); |
| 177 | + interaction.initialize(InitializeSettings { |
| 178 | + configuration: Some(None), |
| 179 | + capabilities: Some(serde_json::json!({ |
| 180 | + "textDocument": { |
| 181 | + "publishDiagnostics": { |
| 182 | + "versionSupport": true, |
| 183 | + }, |
| 184 | + }, |
| 185 | + })), |
| 186 | + ..Default::default() |
| 187 | + }); |
| 188 | + |
| 189 | + interaction.server.did_open("text_document.py"); |
| 190 | + interaction.server.diagnostic("text_document.py"); |
| 191 | + |
| 192 | + interaction |
| 193 | + .client |
| 194 | + .expect_message(lsp_server::Message::Notification( |
| 195 | + lsp_server::Notification { |
| 196 | + method: "textDocument/publishDiagnostics".to_owned(), |
| 197 | + params: serde_json::json! {{ |
| 198 | + "uri": uri, |
| 199 | + "diagnostics": [], |
| 200 | + "version": 1 |
| 201 | + }}, |
| 202 | + }, |
| 203 | + )); |
| 204 | + |
| 205 | + interaction.server.did_change("text_document.py", "# test"); |
| 206 | + interaction.server.diagnostic("text_document.py"); |
| 207 | + |
| 208 | + // I don't understand why this version is still 1 |
| 209 | + interaction |
| 210 | + .client |
| 211 | + .expect_message(lsp_server::Message::Notification( |
| 212 | + lsp_server::Notification { |
| 213 | + method: "textDocument/publishDiagnostics".to_owned(), |
| 214 | + params: serde_json::json! {{ |
| 215 | + "uri": uri, |
| 216 | + "diagnostics": [], |
| 217 | + "version": 2 |
| 218 | + }}, |
| 219 | + }, |
| 220 | + )); |
| 221 | + |
| 222 | + interaction.server.did_close("text_document.py"); |
| 223 | + interaction.server.diagnostic("text_document.py"); |
| 224 | + |
| 225 | + interaction |
| 226 | + .client |
| 227 | + .expect_message(lsp_server::Message::Notification( |
| 228 | + lsp_server::Notification { |
| 229 | + method: "textDocument/publishDiagnostics".to_owned(), |
| 230 | + params: serde_json::json! {{ |
| 231 | + "uri": uri, |
| 232 | + "diagnostics": [], |
| 233 | + "version": 3 |
| 234 | + }}, |
| 235 | + }, |
| 236 | + )); |
| 237 | + |
| 238 | + interaction.shutdown(); |
| 239 | +} |
0 commit comments