Use let else instead of variable and fix some error messages
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
This commit is contained in:
parent
1d5d5dab47
commit
8ab6d7be5e
3 changed files with 19 additions and 21 deletions
|
@ -4093,7 +4093,7 @@ fn format_selections(cx: &mut Context) {
|
||||||
Some(future_offset_encoding) => future_offset_encoding,
|
Some(future_offset_encoding) => future_offset_encoding,
|
||||||
None => {
|
None => {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No language server supports range formatting");
|
.set_error("No configured language server supports range formatting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -389,7 +389,7 @@ pub fn symbol_picker(cx: &mut Context) {
|
||||||
|
|
||||||
if futures.is_empty() {
|
if futures.is_empty() {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No Language server does support document symbols");
|
.set_error("No configured language server supports document symbols");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if futures.is_empty() {
|
if futures.is_empty() {
|
||||||
editor.set_error("No Language server does support workspace symbols");
|
editor.set_error("No configured language server supports workspace symbols");
|
||||||
}
|
}
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
|
@ -663,7 +663,7 @@ pub fn code_action(cx: &mut Context) {
|
||||||
|
|
||||||
if futures.is_empty() {
|
if futures.is_empty() {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No Language server does support code actions");
|
.set_error("No configured language server supports code actions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1043,8 @@ where
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
cx.editor.set_error("No language server supports {feature}");
|
cx.editor
|
||||||
|
.set_error("No configured language server supports {feature}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1107,7 @@ pub fn goto_reference(cx: &mut Context) {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No language server supports goto-reference");
|
.set_error("No configured language server supports goto-reference");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,7 +1139,7 @@ pub fn signature_help_impl(cx: &mut Context, invoked: SignatureHelpInvoked) {
|
||||||
// automatically on backspace, trigger characters, etc.
|
// automatically on backspace, trigger characters, etc.
|
||||||
if invoked == SignatureHelpInvoked::Manual {
|
if invoked == SignatureHelpInvoked::Manual {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No language server supports signature-help");
|
.set_error("No configured language server supports signature-help");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1270,8 @@ pub fn hover(cx: &mut Context) {
|
||||||
let future = match request {
|
let future = match request {
|
||||||
Some(future) => future,
|
Some(future) => future,
|
||||||
None => {
|
None => {
|
||||||
cx.editor.set_error("No language server supports hover");
|
cx.editor
|
||||||
|
.set_error("No configured language server supports hover");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1393,7 +1395,7 @@ pub fn rename_symbol(cx: &mut Context) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No language server supports symbol renaming");
|
.set_error("No configured language server supports symbol renaming");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1459,7 +1461,7 @@ pub fn select_references_to_symbol_under_cursor(cx: &mut Context) {
|
||||||
Some(future_offset_encoding) => future_offset_encoding,
|
Some(future_offset_encoding) => future_offset_encoding,
|
||||||
None => {
|
None => {
|
||||||
cx.editor
|
cx.editor
|
||||||
.set_error("No language server supports document-highlight");
|
.set_error("No configured language server supports document-highlight");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1330,23 +1330,19 @@ fn lsp_workspace_command(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let doc = doc!(cx.editor);
|
let doc = doc!(cx.editor);
|
||||||
let id_options = doc
|
let Some((language_server_id, options)) = doc
|
||||||
.language_servers_with_feature(LanguageServerFeature::WorkspaceCommand)
|
.language_servers_with_feature(LanguageServerFeature::WorkspaceCommand)
|
||||||
.find_map(|ls| {
|
.find_map(|ls| {
|
||||||
ls.capabilities()
|
ls.capabilities()
|
||||||
.execute_command_provider
|
.execute_command_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|options| (ls.id(), options))
|
.map(|options| (ls.id(), options))
|
||||||
});
|
})
|
||||||
|
else {
|
||||||
let (language_server_id, options) = match id_options {
|
cx.editor.set_status(
|
||||||
Some(id_options) => id_options,
|
"No active language servers for this document support workspace commands",
|
||||||
None => {
|
);
|
||||||
cx.editor.set_status(
|
return Ok(());
|
||||||
"No active language servers for this document support workspace commands",
|
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue