agent2: Port user_modifier_to_send
setting (#36550)
Release Notes: - N/A
This commit is contained in:
parent
1e1110ee8c
commit
159b5e9fb5
3 changed files with 51 additions and 5 deletions
|
@ -327,7 +327,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "AcpThread > Editor",
|
"context": "AcpThread > Editor && !use_modifier_to_send",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "agent::Chat",
|
"enter": "agent::Chat",
|
||||||
|
@ -336,6 +336,16 @@
|
||||||
"ctrl-shift-n": "agent::RejectAll"
|
"ctrl-shift-n": "agent::RejectAll"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"context": "AcpThread > Editor && use_modifier_to_send",
|
||||||
|
"use_key_equivalents": true,
|
||||||
|
"bindings": {
|
||||||
|
"ctrl-enter": "agent::Chat",
|
||||||
|
"shift-ctrl-r": "agent::OpenAgentDiff",
|
||||||
|
"ctrl-shift-y": "agent::KeepAll",
|
||||||
|
"ctrl-shift-n": "agent::RejectAll"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"context": "ThreadHistory",
|
"context": "ThreadHistory",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
|
|
|
@ -379,7 +379,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "AcpThread > Editor",
|
"context": "AcpThread > Editor && !use_modifier_to_send",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "agent::Chat",
|
"enter": "agent::Chat",
|
||||||
|
@ -388,6 +388,16 @@
|
||||||
"cmd-shift-n": "agent::RejectAll"
|
"cmd-shift-n": "agent::RejectAll"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"context": "AcpThread > Editor && use_modifier_to_send",
|
||||||
|
"use_key_equivalents": true,
|
||||||
|
"bindings": {
|
||||||
|
"cmd-enter": "agent::Chat",
|
||||||
|
"shift-ctrl-r": "agent::OpenAgentDiff",
|
||||||
|
"cmd-shift-y": "agent::KeepAll",
|
||||||
|
"cmd-shift-n": "agent::RejectAll"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"context": "ThreadHistory",
|
"context": "ThreadHistory",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use anyhow::{Context as _, Result, anyhow};
|
||||||
use assistant_slash_commands::codeblock_fence_for_path;
|
use assistant_slash_commands::codeblock_fence_for_path;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{
|
use editor::{
|
||||||
Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement,
|
Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement,
|
||||||
EditorEvent, EditorMode, EditorStyle, ExcerptId, FoldPlaceholder, MultiBuffer,
|
EditorEvent, EditorMode, EditorStyle, ExcerptId, FoldPlaceholder, MultiBuffer,
|
||||||
SemanticsProvider, ToOffset,
|
SemanticsProvider, ToOffset,
|
||||||
actions::Paste,
|
actions::Paste,
|
||||||
|
@ -21,8 +21,8 @@ use futures::{
|
||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AppContext, ClipboardEntry, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
AppContext, ClipboardEntry, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||||
HighlightStyle, Image, ImageFormat, Img, Subscription, Task, TextStyle, UnderlineStyle,
|
HighlightStyle, Image, ImageFormat, Img, KeyContext, Subscription, Task, TextStyle,
|
||||||
WeakEntity,
|
UnderlineStyle, WeakEntity,
|
||||||
};
|
};
|
||||||
use language::{Buffer, Language};
|
use language::{Buffer, Language};
|
||||||
use language_model::LanguageModelImage;
|
use language_model::LanguageModelImage;
|
||||||
|
@ -122,6 +122,7 @@ impl MessageEditor {
|
||||||
if prevent_slash_commands {
|
if prevent_slash_commands {
|
||||||
editor.set_semantics_provider(Some(semantics_provider.clone()));
|
editor.set_semantics_provider(Some(semantics_provider.clone()));
|
||||||
}
|
}
|
||||||
|
editor.register_addon(MessageEditorAddon::new());
|
||||||
editor
|
editor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1648,6 +1649,31 @@ fn parse_slash_command(text: &str) -> Option<(usize, usize)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct MessageEditorAddon {}
|
||||||
|
|
||||||
|
impl MessageEditorAddon {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Addon for MessageEditorAddon {
|
||||||
|
fn to_any(&self) -> &dyn std::any::Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_any_mut(&mut self) -> Option<&mut dyn std::any::Any> {
|
||||||
|
Some(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extend_key_context(&self, key_context: &mut KeyContext, cx: &App) {
|
||||||
|
let settings = agent_settings::AgentSettings::get_global(cx);
|
||||||
|
if settings.use_modifier_to_send {
|
||||||
|
key_context.add("use_modifier_to_send");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{ops::Range, path::Path, sync::Arc};
|
use std::{ops::Range, path::Path, sync::Arc};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue