1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

tests(lsp): regression test for providing completions when editing documents (#12776)

Ref: #12753
This commit is contained in:
Yacine Hmito 2021-11-16 03:59:33 +01:00 committed by GitHub
parent 01644488ae
commit f9f9ddc5e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();