assistant: Replace an expect
with a precondition check (#12292)
This PR replaces an `expect` with a precondition check to avoid a panic if the `LspAdapterDelegate` isn't set when invoking a slash command. Release Notes: - N/A
This commit is contained in:
parent
8450d63ed6
commit
78aaa29d5b
1 changed files with 6 additions and 8 deletions
|
@ -1858,20 +1858,18 @@ impl Conversation {
|
||||||
let name = &line[call.name];
|
let name = &line[call.name];
|
||||||
if let Some(call) = unchanged_call {
|
if let Some(call) = unchanged_call {
|
||||||
new_calls.push(call);
|
new_calls.push(call);
|
||||||
} else if let Some(command) = this.slash_command_registry.command(name) {
|
} else if let Some((command, lsp_adapter_delegate)) = this
|
||||||
|
.slash_command_registry
|
||||||
|
.command(name)
|
||||||
|
.zip(this.lsp_adapter_delegate.clone())
|
||||||
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
let name = name.to_string();
|
let name = name.to_string();
|
||||||
let source_range =
|
let source_range =
|
||||||
buffer.anchor_after(offset)..buffer.anchor_before(line_end_offset);
|
buffer.anchor_after(offset)..buffer.anchor_before(line_end_offset);
|
||||||
|
|
||||||
let argument = call.argument.map(|range| &line[range]);
|
let argument = call.argument.map(|range| &line[range]);
|
||||||
let invocation = command.run(
|
let invocation = command.run(argument, lsp_adapter_delegate, cx);
|
||||||
argument,
|
|
||||||
this.lsp_adapter_delegate
|
|
||||||
.clone()
|
|
||||||
.expect("no LspAdapterDelegate present when invoking command"),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
new_calls.push(SlashCommandCall {
|
new_calls.push(SlashCommandCall {
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue