Display default prompts more elaborately (#16471)
Show them under `User` role instead of a `System` one, and insert them expanded. Release Notes: - N/A
This commit is contained in:
parent
bac8e81e73
commit
69aae2037d
4 changed files with 32 additions and 4 deletions
|
@ -1808,7 +1808,7 @@ impl ContextEditor {
|
||||||
};
|
};
|
||||||
this.update_message_headers(cx);
|
this.update_message_headers(cx);
|
||||||
this.update_image_blocks(cx);
|
this.update_image_blocks(cx);
|
||||||
this.insert_slash_command_output_sections(sections, cx);
|
this.insert_slash_command_output_sections(sections, false, cx);
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1821,7 +1821,7 @@ impl ContextEditor {
|
||||||
let command = self.context.update(cx, |context, cx| {
|
let command = self.context.update(cx, |context, cx| {
|
||||||
let first_message_id = context.messages(cx).next().unwrap().id;
|
let first_message_id = context.messages(cx).next().unwrap().id;
|
||||||
context.update_metadata(first_message_id, cx, |metadata| {
|
context.update_metadata(first_message_id, cx, |metadata| {
|
||||||
metadata.role = Role::System;
|
metadata.role = Role::User;
|
||||||
});
|
});
|
||||||
context.reparse_slash_commands(cx);
|
context.reparse_slash_commands(cx);
|
||||||
context.pending_slash_commands()[0].clone()
|
context.pending_slash_commands()[0].clone()
|
||||||
|
@ -1832,6 +1832,7 @@ impl ContextEditor {
|
||||||
&command.name,
|
&command.name,
|
||||||
&command.arguments,
|
&command.arguments,
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
self.workspace.clone(),
|
self.workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -2098,6 +2099,7 @@ impl ContextEditor {
|
||||||
&command.name,
|
&command.name,
|
||||||
&command.arguments,
|
&command.arguments,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -2106,19 +2108,27 @@ impl ContextEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn run_command(
|
pub fn run_command(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_range: Range<language::Anchor>,
|
command_range: Range<language::Anchor>,
|
||||||
name: &str,
|
name: &str,
|
||||||
arguments: &[String],
|
arguments: &[String],
|
||||||
ensure_trailing_newline: bool,
|
ensure_trailing_newline: bool,
|
||||||
|
expand_result: bool,
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(command) = SlashCommandRegistry::global(cx).command(name) {
|
if let Some(command) = SlashCommandRegistry::global(cx).command(name) {
|
||||||
let output = command.run(arguments, workspace, self.lsp_adapter_delegate.clone(), cx);
|
let output = command.run(arguments, workspace, self.lsp_adapter_delegate.clone(), cx);
|
||||||
self.context.update(cx, |context, cx| {
|
self.context.update(cx, |context, cx| {
|
||||||
context.insert_command_output(command_range, output, ensure_trailing_newline, cx)
|
context.insert_command_output(
|
||||||
|
command_range,
|
||||||
|
output,
|
||||||
|
ensure_trailing_newline,
|
||||||
|
expand_result,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2204,6 +2214,7 @@ impl ContextEditor {
|
||||||
&command.name,
|
&command.name,
|
||||||
&command.arguments,
|
&command.arguments,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -2300,8 +2311,13 @@ impl ContextEditor {
|
||||||
output_range,
|
output_range,
|
||||||
sections,
|
sections,
|
||||||
run_commands_in_output,
|
run_commands_in_output,
|
||||||
|
expand_result,
|
||||||
} => {
|
} => {
|
||||||
self.insert_slash_command_output_sections(sections.iter().cloned(), cx);
|
self.insert_slash_command_output_sections(
|
||||||
|
sections.iter().cloned(),
|
||||||
|
*expand_result,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
|
||||||
if *run_commands_in_output {
|
if *run_commands_in_output {
|
||||||
let commands = self.context.update(cx, |context, cx| {
|
let commands = self.context.update(cx, |context, cx| {
|
||||||
|
@ -2317,6 +2333,7 @@ impl ContextEditor {
|
||||||
&command.name,
|
&command.name,
|
||||||
&command.arguments,
|
&command.arguments,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
self.workspace.clone(),
|
self.workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -2333,6 +2350,7 @@ impl ContextEditor {
|
||||||
fn insert_slash_command_output_sections(
|
fn insert_slash_command_output_sections(
|
||||||
&mut self,
|
&mut self,
|
||||||
sections: impl IntoIterator<Item = SlashCommandOutputSection<language::Anchor>>,
|
sections: impl IntoIterator<Item = SlashCommandOutputSection<language::Anchor>>,
|
||||||
|
expand_result: bool,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
self.editor.update(cx, |editor, cx| {
|
self.editor.update(cx, |editor, cx| {
|
||||||
|
@ -2387,6 +2405,9 @@ impl ContextEditor {
|
||||||
|
|
||||||
editor.insert_creases(creases, cx);
|
editor.insert_creases(creases, cx);
|
||||||
|
|
||||||
|
if expand_result {
|
||||||
|
buffer_rows_to_fold.clear();
|
||||||
|
}
|
||||||
for buffer_row in buffer_rows_to_fold.into_iter().rev() {
|
for buffer_row in buffer_rows_to_fold.into_iter().rev() {
|
||||||
editor.fold_at(&FoldAt { buffer_row }, cx);
|
editor.fold_at(&FoldAt { buffer_row }, cx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,6 +295,7 @@ pub enum ContextEvent {
|
||||||
output_range: Range<language::Anchor>,
|
output_range: Range<language::Anchor>,
|
||||||
sections: Vec<SlashCommandOutputSection<language::Anchor>>,
|
sections: Vec<SlashCommandOutputSection<language::Anchor>>,
|
||||||
run_commands_in_output: bool,
|
run_commands_in_output: bool,
|
||||||
|
expand_result: bool,
|
||||||
},
|
},
|
||||||
Operation(ContextOperation),
|
Operation(ContextOperation),
|
||||||
}
|
}
|
||||||
|
@ -774,6 +775,7 @@ impl Context {
|
||||||
cx.emit(ContextEvent::SlashCommandFinished {
|
cx.emit(ContextEvent::SlashCommandFinished {
|
||||||
output_range,
|
output_range,
|
||||||
sections,
|
sections,
|
||||||
|
expand_result: false,
|
||||||
run_commands_in_output: false,
|
run_commands_in_output: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1396,6 +1398,7 @@ impl Context {
|
||||||
command_range: Range<language::Anchor>,
|
command_range: Range<language::Anchor>,
|
||||||
output: Task<Result<SlashCommandOutput>>,
|
output: Task<Result<SlashCommandOutput>>,
|
||||||
ensure_trailing_newline: bool,
|
ensure_trailing_newline: bool,
|
||||||
|
expand_result: bool,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
self.reparse_slash_commands(cx);
|
self.reparse_slash_commands(cx);
|
||||||
|
@ -1469,6 +1472,7 @@ impl Context {
|
||||||
output_range,
|
output_range,
|
||||||
sections,
|
sections,
|
||||||
run_commands_in_output: output.run_commands_in_text,
|
run_commands_in_output: output.run_commands_in_text,
|
||||||
|
expand_result,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -891,6 +891,7 @@ async fn test_random_context_collaboration(cx: &mut TestAppContext, mut rng: Std
|
||||||
run_commands_in_text: false,
|
run_commands_in_text: false,
|
||||||
})),
|
})),
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -124,6 +124,7 @@ impl SlashCommandCompletionProvider {
|
||||||
&command_name,
|
&command_name,
|
||||||
&[],
|
&[],
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -208,6 +209,7 @@ impl SlashCommandCompletionProvider {
|
||||||
&command_name,
|
&command_name,
|
||||||
&completed_arguments,
|
&completed_arguments,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue