Fix regression in producing sections when converting SlashCommandOutput to event stream (#20404)

Closes #20243 

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2024-11-08 09:29:14 +01:00 committed by GitHub
parent 8cc3ce1f17
commit 2fe9cd8faa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 60 deletions

View file

@ -1983,7 +1983,7 @@ impl Context {
run_commands_in_ranges.push(start..end);
}
}
SlashCommandEvent::EndSection { metadata } => {
SlashCommandEvent::EndSection => {
if let Some(pending_section) = pending_section_stack.pop() {
let offset_range = (pending_section.start..insert_position)
.to_offset(this.buffer.read(cx));
@ -1997,7 +1997,7 @@ impl Context {
range: range.clone(),
icon: pending_section.icon,
label: pending_section.label,
metadata: metadata.or(pending_section.metadata),
metadata: pending_section.metadata,
},
cx,
);

View file

@ -583,7 +583,7 @@ async fn test_slash_commands(cx: &mut TestAppContext) {
);
command_output_tx
.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))
.unbounded_send(Ok(SlashCommandEvent::EndSection))
.unwrap();
cx.run_until_parked();
assert_text_and_context_ranges(
@ -1310,7 +1310,7 @@ async fn test_random_context_collaboration(cx: &mut TestAppContext, mut rng: Std
text: output_text[section_start..section_end].to_string(),
run_commands_in_text: false,
})));
events.push(Ok(SlashCommandEvent::EndSection { metadata: None }));
events.push(Ok(SlashCommandEvent::EndSection));
section_start = section_end;
}

View file

@ -256,8 +256,7 @@ fn collect_files(
break;
}
directory_stack.pop().unwrap();
events_tx
.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::Content(
SlashCommandContent::Text {
text: "\n".into(),
@ -362,7 +361,7 @@ fn collect_files(
}
while let Some(_) = directory_stack.pop() {
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
}
}

View file

@ -84,7 +84,7 @@ impl SlashCommand for SelectionCommand {
text,
run_commands_in_text: false,
})));
events.push(Ok(SlashCommandEvent::EndSection { metadata: None }));
events.push(Ok(SlashCommandEvent::EndSection));
events.push(Ok(SlashCommandEvent::Content(SlashCommandContent::Text {
text: "\n".to_string(),
run_commands_in_text: false,

View file

@ -74,7 +74,7 @@ impl SlashCommand for StreamingExampleSlashCommand {
run_commands_in_text: false,
},
)))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
Timer::after(Duration::from_secs(1)).await;
@ -89,7 +89,7 @@ impl SlashCommand for StreamingExampleSlashCommand {
run_commands_in_text: false,
},
)))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
for n in 1..=10 {
Timer::after(Duration::from_secs(1)).await;
@ -105,8 +105,7 @@ impl SlashCommand for StreamingExampleSlashCommand {
run_commands_in_text: false,
},
)))?;
events_tx
.unbounded_send(Ok(SlashCommandEvent::EndSection { metadata: None }))?;
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
}
anyhow::Ok(())