Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -1076,20 +1076,20 @@ impl AssistantContext {
|
|||
timestamp,
|
||||
..
|
||||
} => {
|
||||
if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id) {
|
||||
if timestamp > slash_command.timestamp {
|
||||
slash_command.timestamp = timestamp;
|
||||
match error_message {
|
||||
Some(message) => {
|
||||
slash_command.status =
|
||||
InvokedSlashCommandStatus::Error(message.into());
|
||||
}
|
||||
None => {
|
||||
slash_command.status = InvokedSlashCommandStatus::Finished;
|
||||
}
|
||||
if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id)
|
||||
&& timestamp > slash_command.timestamp
|
||||
{
|
||||
slash_command.timestamp = timestamp;
|
||||
match error_message {
|
||||
Some(message) => {
|
||||
slash_command.status =
|
||||
InvokedSlashCommandStatus::Error(message.into());
|
||||
}
|
||||
None => {
|
||||
slash_command.status = InvokedSlashCommandStatus::Finished;
|
||||
}
|
||||
cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id });
|
||||
}
|
||||
cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id });
|
||||
}
|
||||
}
|
||||
ContextOperation::BufferOperation(_) => unreachable!(),
|
||||
|
@ -1368,10 +1368,10 @@ impl AssistantContext {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(last_anchor) = last_anchor {
|
||||
if message.id == last_anchor {
|
||||
hit_last_anchor = true;
|
||||
}
|
||||
if let Some(last_anchor) = last_anchor
|
||||
&& message.id == last_anchor
|
||||
{
|
||||
hit_last_anchor = true;
|
||||
}
|
||||
|
||||
new_anchor_needs_caching = new_anchor_needs_caching
|
||||
|
@ -1406,10 +1406,10 @@ impl AssistantContext {
|
|||
if !self.pending_completions.is_empty() {
|
||||
return;
|
||||
}
|
||||
if let Some(cache_configuration) = cache_configuration {
|
||||
if !cache_configuration.should_speculate {
|
||||
return;
|
||||
}
|
||||
if let Some(cache_configuration) = cache_configuration
|
||||
&& !cache_configuration.should_speculate
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let request = {
|
||||
|
@ -1552,25 +1552,24 @@ impl AssistantContext {
|
|||
})
|
||||
.map(ToOwned::to_owned)
|
||||
.collect::<SmallVec<_>>();
|
||||
if let Some(command) = self.slash_commands.command(name, cx) {
|
||||
if !command.requires_argument() || !arguments.is_empty() {
|
||||
let start_ix = offset + command_line.name.start - 1;
|
||||
let end_ix = offset
|
||||
+ command_line
|
||||
.arguments
|
||||
.last()
|
||||
.map_or(command_line.name.end, |argument| argument.end);
|
||||
let source_range =
|
||||
buffer.anchor_after(start_ix)..buffer.anchor_after(end_ix);
|
||||
let pending_command = ParsedSlashCommand {
|
||||
name: name.to_string(),
|
||||
arguments,
|
||||
source_range,
|
||||
status: PendingSlashCommandStatus::Idle,
|
||||
};
|
||||
updated.push(pending_command.clone());
|
||||
new_commands.push(pending_command);
|
||||
}
|
||||
if let Some(command) = self.slash_commands.command(name, cx)
|
||||
&& (!command.requires_argument() || !arguments.is_empty())
|
||||
{
|
||||
let start_ix = offset + command_line.name.start - 1;
|
||||
let end_ix = offset
|
||||
+ command_line
|
||||
.arguments
|
||||
.last()
|
||||
.map_or(command_line.name.end, |argument| argument.end);
|
||||
let source_range = buffer.anchor_after(start_ix)..buffer.anchor_after(end_ix);
|
||||
let pending_command = ParsedSlashCommand {
|
||||
name: name.to_string(),
|
||||
arguments,
|
||||
source_range,
|
||||
status: PendingSlashCommandStatus::Idle,
|
||||
};
|
||||
updated.push(pending_command.clone());
|
||||
new_commands.push(pending_command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1799,14 +1798,13 @@ impl AssistantContext {
|
|||
});
|
||||
|
||||
let end = this.buffer.read(cx).anchor_before(insert_position);
|
||||
if run_commands_in_text {
|
||||
if let Some(invoked_slash_command) =
|
||||
if run_commands_in_text
|
||||
&& let Some(invoked_slash_command) =
|
||||
this.invoked_slash_commands.get_mut(&command_id)
|
||||
{
|
||||
invoked_slash_command
|
||||
.run_commands_in_ranges
|
||||
.push(start..end);
|
||||
}
|
||||
{
|
||||
invoked_slash_command
|
||||
.run_commands_in_ranges
|
||||
.push(start..end);
|
||||
}
|
||||
}
|
||||
SlashCommandEvent::EndSection => {
|
||||
|
@ -2741,10 +2739,10 @@ impl AssistantContext {
|
|||
}
|
||||
|
||||
this.read_with(cx, |this, _cx| {
|
||||
if let Some(summary) = this.summary.content() {
|
||||
if summary.text.is_empty() {
|
||||
bail!("Model generated an empty summary");
|
||||
}
|
||||
if let Some(summary) = this.summary.content()
|
||||
&& summary.text.is_empty()
|
||||
{
|
||||
bail!("Model generated an empty summary");
|
||||
}
|
||||
Ok(())
|
||||
})??;
|
||||
|
@ -2924,18 +2922,18 @@ impl AssistantContext {
|
|||
fs.create_dir(contexts_dir().as_ref()).await?;
|
||||
|
||||
// rename before write ensures that only one file exists
|
||||
if let Some(old_path) = old_path.as_ref() {
|
||||
if new_path.as_path() != old_path.as_ref() {
|
||||
fs.rename(
|
||||
old_path,
|
||||
&new_path,
|
||||
RenameOptions {
|
||||
overwrite: true,
|
||||
ignore_if_exists: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
if let Some(old_path) = old_path.as_ref()
|
||||
&& new_path.as_path() != old_path.as_ref()
|
||||
{
|
||||
fs.rename(
|
||||
old_path,
|
||||
&new_path,
|
||||
RenameOptions {
|
||||
overwrite: true,
|
||||
ignore_if_exists: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
// update path before write in case it fails
|
||||
|
|
|
@ -894,34 +894,33 @@ impl ContextStore {
|
|||
return;
|
||||
};
|
||||
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Prompts) {
|
||||
if let Some(response) = protocol
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Prompts)
|
||||
&& let Some(response) = protocol
|
||||
.request::<context_server::types::requests::PromptsList>(())
|
||||
.await
|
||||
.log_err()
|
||||
{
|
||||
let slash_command_ids = response
|
||||
.prompts
|
||||
.into_iter()
|
||||
.filter(assistant_slash_commands::acceptable_prompt)
|
||||
.map(|prompt| {
|
||||
log::info!("registering context server command: {:?}", prompt.name);
|
||||
slash_command_working_set.insert(Arc::new(
|
||||
assistant_slash_commands::ContextServerSlashCommand::new(
|
||||
context_server_store.clone(),
|
||||
server.id(),
|
||||
prompt,
|
||||
),
|
||||
))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
this.update(cx, |this, _cx| {
|
||||
this.context_server_slash_command_ids
|
||||
.insert(server_id.clone(), slash_command_ids);
|
||||
{
|
||||
let slash_command_ids = response
|
||||
.prompts
|
||||
.into_iter()
|
||||
.filter(assistant_slash_commands::acceptable_prompt)
|
||||
.map(|prompt| {
|
||||
log::info!("registering context server command: {:?}", prompt.name);
|
||||
slash_command_working_set.insert(Arc::new(
|
||||
assistant_slash_commands::ContextServerSlashCommand::new(
|
||||
context_server_store.clone(),
|
||||
server.id(),
|
||||
prompt,
|
||||
),
|
||||
))
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
this.update(cx, |this, _cx| {
|
||||
this.context_server_slash_command_ids
|
||||
.insert(server_id.clone(), slash_command_ids);
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue