mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 17:49:08 -05:00
fix(lsp): completions for private variables (#17220)
This commit is contained in:
parent
4a1a6b7985
commit
b9768e2338
2 changed files with 45 additions and 2 deletions
|
@ -2205,7 +2205,7 @@ impl CompletionEntry {
|
|||
return Some(insert_text.clone());
|
||||
}
|
||||
} else {
|
||||
return Some(self.name.replace('#', ""));
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4060,7 +4060,7 @@ mod tests {
|
|||
..Default::default()
|
||||
};
|
||||
let actual = fixture.get_filter_text();
|
||||
assert_eq!(actual, Some("abc".to_string()));
|
||||
assert_eq!(actual, None);
|
||||
|
||||
let fixture = CompletionEntry {
|
||||
kind: ScriptElementKind::MemberVariableElement,
|
||||
|
|
|
@ -3738,6 +3738,49 @@ export class DuckConfig {
|
|||
shutdown(&mut client);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_completions_private_fields() {
|
||||
let mut client = init("initialize_params.json");
|
||||
did_open(
|
||||
&mut client,
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "file:///a/file.ts",
|
||||
"languageId": "typescript",
|
||||
"version": 1,
|
||||
"text": r#"class Foo { #myProperty = "value"; constructor() { this.# } }"#
|
||||
}
|
||||
}),
|
||||
);
|
||||
let (maybe_res, maybe_err) = client
|
||||
.write_request(
|
||||
"textDocument/completion",
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "file:///a/file.ts"
|
||||
},
|
||||
"position": {
|
||||
"line": 0,
|
||||
"character": 57
|
||||
},
|
||||
"context": {
|
||||
"triggerKind": 1
|
||||
}
|
||||
}),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(maybe_err.is_none());
|
||||
if let Some(lsp::CompletionResponse::List(list)) = maybe_res {
|
||||
assert_eq!(list.items.len(), 1);
|
||||
let item = &list.items[0];
|
||||
assert_eq!(item.label, "#myProperty");
|
||||
assert!(!list.is_incomplete);
|
||||
} else {
|
||||
panic!("unexpected response");
|
||||
}
|
||||
shutdown(&mut client);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_completions_optional() {
|
||||
let mut client = init("initialize_params.json");
|
||||
|
|
Loading…
Reference in a new issue