summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-04-01 20:18:51 +1100
committerGitHub <noreply@github.com>2021-04-01 20:18:51 +1100
commitec6317e8944d87cb412128f44fe4bb4c2a2d136f (patch)
treedfe91598fb706fde6455c127d0d655af0faaf56e /cli/lsp/language_server.rs
parent47ac654ea27e22d328921dd2283953dfd675b427 (diff)
fix(lsp): ensure insert_text is passed back on completions (#9951)
Fixes #9920
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 74dcf2136..b55c38189 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -3025,6 +3025,68 @@ mod tests {
harness.run().await;
}
+ #[tokio::test]
+ async fn test_completions_optional() {
+ let mut harness = LspTestHarness::new(vec![
+ ("initialize_request.json", LspResponse::RequestAny),
+ ("initialized_notification.json", LspResponse::None),
+ (
+ "did_open_notification_completion_optional.json",
+ LspResponse::None,
+ ),
+ (
+ "completion_request_optional.json",
+ LspResponse::Request(
+ 2,
+ json!({
+ "isIncomplete": false,
+ "items": [
+ {
+ "label": "b?",
+ "kind": 5,
+ "sortText": "1",
+ "filterText": "b",
+ "insertText": "b",
+ "data": {
+ "tsc": {
+ "specifier": "file:///a/file.ts",
+ "position": 79,
+ "name": "b",
+ "useCodeSnippet": false
+ }
+ }
+ }
+ ]
+ }),
+ ),
+ ),
+ (
+ "completion_resolve_request_optional.json",
+ LspResponse::Request(
+ 4,
+ json!({
+ "label": "b?",
+ "kind": 5,
+ "detail": "(property) A.b?: string | undefined",
+ "documentation": {
+ "kind": "markdown",
+ "value": ""
+ },
+ "sortText": "1",
+ "filterText": "b",
+ "insertText": "b"
+ }),
+ ),
+ ),
+ (
+ "shutdown_request.json",
+ LspResponse::Request(3, json!(null)),
+ ),
+ ("exit_notification.json", LspResponse::None),
+ ]);
+ harness.run().await;
+ }
+
#[derive(Deserialize)]
struct PerformanceAverages {
averages: Vec<PerformanceAverage>,