Add '
to trigger_characters, allowing more direct lifetime completions
This commit is contained in:
parent
2280f62a40
commit
f3c7499be5
@ -68,6 +68,16 @@ fn func<'lifetime>(foo: &'li$0) {}
|
|||||||
"#,
|
"#,
|
||||||
r#"
|
r#"
|
||||||
fn func<'lifetime>(foo: &'lifetime) {}
|
fn func<'lifetime>(foo: &'lifetime) {}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
cov_mark::check!(completes_if_lifetime_without_idents);
|
||||||
|
check_edit(
|
||||||
|
"'lifetime",
|
||||||
|
r#"
|
||||||
|
fn func<'lifetime>(foo: &'$0) {}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
fn func<'lifetime>(foo: &'lifetime) {}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -191,6 +201,27 @@ fn foo<'footime, 'lifetime: 'a$0>() {}
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_label_edit() {
|
||||||
|
check_edit(
|
||||||
|
"'label",
|
||||||
|
r#"
|
||||||
|
fn foo() {
|
||||||
|
'label: loop {
|
||||||
|
break '$0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
fn foo() {
|
||||||
|
'label: loop {
|
||||||
|
break 'label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_label_in_loop() {
|
fn complete_label_in_loop() {
|
||||||
check(
|
check(
|
||||||
|
@ -255,6 +255,10 @@ impl<'a> CompletionContext<'a> {
|
|||||||
if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() {
|
if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() {
|
||||||
cov_mark::hit!(completes_if_prefix_is_keyword);
|
cov_mark::hit!(completes_if_prefix_is_keyword);
|
||||||
self.original_token.text_range()
|
self.original_token.text_range()
|
||||||
|
} else if kind == CHAR {
|
||||||
|
// assume we are completing a lifetime but the user has only typed the '
|
||||||
|
cov_mark::hit!(completes_if_lifetime_without_idents);
|
||||||
|
TextRange::at(self.original_token.text_range().start(), TextSize::from(1))
|
||||||
} else {
|
} else {
|
||||||
TextRange::empty(self.position.offset)
|
TextRange::empty(self.position.offset)
|
||||||
}
|
}
|
||||||
@ -471,7 +475,7 @@ impl<'a> CompletionContext<'a> {
|
|||||||
self.lifetime_syntax =
|
self.lifetime_syntax =
|
||||||
find_node_at_offset(original_file, lifetime.syntax().text_range().start());
|
find_node_at_offset(original_file, lifetime.syntax().text_range().start());
|
||||||
if let Some(parent) = lifetime.syntax().parent() {
|
if let Some(parent) = lifetime.syntax().parent() {
|
||||||
if parent.kind() == syntax::SyntaxKind::ERROR {
|
if parent.kind() == ERROR {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
|
|||||||
hover_provider: Some(HoverProviderCapability::Simple(true)),
|
hover_provider: Some(HoverProviderCapability::Simple(true)),
|
||||||
completion_provider: Some(CompletionOptions {
|
completion_provider: Some(CompletionOptions {
|
||||||
resolve_provider: completions_resolve_provider(client_caps),
|
resolve_provider: completions_resolve_provider(client_caps),
|
||||||
trigger_characters: Some(vec![":".to_string(), ".".to_string()]),
|
trigger_characters: Some(vec![":".to_string(), ".".to_string(), "'".to_string()]),
|
||||||
all_commit_characters: None,
|
all_commit_characters: None,
|
||||||
completion_item: None,
|
completion_item: None,
|
||||||
work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
|
work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user