summaryrefslogtreecommitdiff
path: root/cli/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorYacine Hmito <yacinehmito@users.noreply.github.com>2021-11-16 03:59:33 +0100
committerGitHub <noreply@github.com>2021-11-16 13:59:33 +1100
commitf9f9ddc5e308809343bbf5c07d4487df5a1b93cf (patch)
tree0363e9568ba9fb0b916536b14bf8e378a837ee47 /cli/tests/integration/lsp_tests.rs
parent01644488ae58840bb2b9d1152f713a2f939cea69 (diff)
tests(lsp): regression test for providing completions when editing documents (#12776)
Ref: #12753
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r--cli/tests/integration/lsp_tests.rs130
1 files changed, 130 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index fc4f6dbc6..96689f8a3 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -1066,6 +1066,136 @@ fn lsp_hover_dependency() {
);
}
+// Regression test for #12753
+#[test]
+#[ignore]
+fn lsp_hover_keep_type_info_after_invalid_syntax_change() {
+ let mut client = init("initialize_params.json");
+ did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file1.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "export type Foo = { bar(): string };\n"
+ }
+ }),
+ );
+ did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file2.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "import { Foo } from './file1.ts'; declare const f: Foo; f\n"
+ }
+ }),
+ );
+ let (maybe_res, maybe_error) = client
+ .write_request::<_, _, Value>(
+ "textDocument/hover",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file2.ts"
+ },
+ "position": {
+ "line": 0,
+ "character": 56
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_error.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(json!({
+ "contents": [
+ {
+ "language": "typescript",
+ "value": "const f: Foo",
+ },
+ ""
+ ],
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 56,
+ },
+ "end": {
+ "line": 0,
+ "character": 57,
+ }
+ }
+ }))
+ );
+ client
+ .write_notification(
+ "textDocument/didChange",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file2.ts",
+ "version": 2
+ },
+ "contentChanges": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 57
+ },
+ "end": {
+ "line": 0,
+ "character": 58
+ }
+ },
+ "text": "."
+ }
+ ]
+ }),
+ )
+ .unwrap();
+ let (maybe_res, maybe_error) = client
+ .write_request::<_, _, Value>(
+ "textDocument/hover",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file2.ts"
+ },
+ "position": {
+ "line": 0,
+ "character": 56
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_error.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(json!({
+ "contents": [
+ {
+ "language": "typescript",
+ "value": "const f: Foo",
+ },
+ ""
+ ],
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 56,
+ },
+ "end": {
+ "line": 0,
+ "character": 57,
+ }
+ }
+ }))
+ );
+ shutdown(&mut client);
+}
+
#[test]
fn lsp_hover_typescript_types() {
let _g = http_server();