fix(tui): expose mention behavior in config
This commit is contained in:
@@ -595,6 +595,11 @@ pub fn set_config_value(app: &mut App, key: &str, value: &str, persist: bool) ->
|
||||
app.composer.mention_completion_cache = None;
|
||||
app.needs_redraw = true;
|
||||
}
|
||||
"mention_menu_behavior" | "mention_behavior" | "mention_menu" => {
|
||||
app.mention_menu_behavior = settings.mention_menu_behavior.clone();
|
||||
app.composer.mention_completion_cache = None;
|
||||
app.needs_redraw = true;
|
||||
}
|
||||
"mention_walk_depth" | "mention_depth" | "completions_walk_depth" => {
|
||||
app.mention_walk_depth = settings.mention_walk_depth;
|
||||
app.composer.mention_completion_cache = None;
|
||||
|
||||
@@ -68,6 +68,7 @@ pub struct SettingsSection {
|
||||
pub composer_vim_mode: ComposerVimModeValue,
|
||||
#[schemars(range(min = 0))]
|
||||
pub mention_menu_limit: usize,
|
||||
pub mention_menu_behavior: MentionMenuBehaviorValue,
|
||||
#[schemars(range(min = 0))]
|
||||
pub mention_walk_depth: usize,
|
||||
pub transcript_spacing: TranscriptSpacingValue,
|
||||
@@ -204,6 +205,13 @@ pub enum ComposerVimModeValue {
|
||||
Vim,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MentionMenuBehaviorValue {
|
||||
Fuzzy,
|
||||
Browser,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TranscriptSpacingValue {
|
||||
@@ -332,6 +340,7 @@ pub fn build_document(app: &App, config: &Config) -> Result<ConfigUiDocument> {
|
||||
composer_border: settings.composer_border,
|
||||
composer_vim_mode: settings.composer_vim_mode.as_str().into(),
|
||||
mention_menu_limit: settings.mention_menu_limit,
|
||||
mention_menu_behavior: settings.mention_menu_behavior.as_str().into(),
|
||||
mention_walk_depth: settings.mention_walk_depth,
|
||||
transcript_spacing: settings.transcript_spacing.as_str().into(),
|
||||
status_indicator: settings.status_indicator.as_str().into(),
|
||||
@@ -513,6 +522,10 @@ pub fn apply_document(
|
||||
"mention_menu_limit",
|
||||
&doc.settings.mention_menu_limit.to_string(),
|
||||
),
|
||||
(
|
||||
"mention_menu_behavior",
|
||||
doc.settings.mention_menu_behavior.as_setting(),
|
||||
),
|
||||
(
|
||||
"mention_walk_depth",
|
||||
&doc.settings.mention_walk_depth.to_string(),
|
||||
@@ -782,6 +795,24 @@ impl From<&str> for ComposerVimModeValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl MentionMenuBehaviorValue {
|
||||
fn as_setting(self) -> &'static str {
|
||||
match self {
|
||||
Self::Fuzzy => "fuzzy",
|
||||
Self::Browser => "browser",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for MentionMenuBehaviorValue {
|
||||
fn from(value: &str) -> Self {
|
||||
match value.trim().to_ascii_lowercase().as_str() {
|
||||
"browser" => Self::Browser,
|
||||
_ => Self::Fuzzy,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TranscriptSpacingValue {
|
||||
fn as_setting(self) -> &'static str {
|
||||
match self {
|
||||
|
||||
@@ -772,6 +772,13 @@ impl ConfigView {
|
||||
editable: true,
|
||||
scope: ConfigScope::Saved,
|
||||
},
|
||||
ConfigRow {
|
||||
section: ConfigSection::Composer,
|
||||
key: "mention_menu_behavior".to_string(),
|
||||
value: settings.mention_menu_behavior.clone(),
|
||||
editable: true,
|
||||
scope: ConfigScope::Saved,
|
||||
},
|
||||
ConfigRow {
|
||||
section: ConfigSection::Composer,
|
||||
key: "mention_walk_depth".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user