feat(config): add undo_backspace option
This commit is contained in:
parent
97130e972c
commit
eab305d45f
|
@ -117,6 +117,10 @@ pub trait Config: Send + Sync {
|
|||
// Hotkey used to trigger the Search UI
|
||||
fn search_shortcut(&self) -> Option<String>;
|
||||
|
||||
// When enabled, espanso automatically "reverts" an expansion if the user
|
||||
// presses the Backspace key afterwards.
|
||||
fn undo_backspace(&self) -> bool;
|
||||
|
||||
fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool;
|
||||
|
||||
fn pretty_dump(&self) -> String {
|
||||
|
|
|
@ -39,6 +39,7 @@ pub(crate) struct ParsedConfig {
|
|||
pub apply_patch: Option<bool>,
|
||||
pub search_trigger: Option<String>,
|
||||
pub search_shortcut: Option<String>,
|
||||
pub undo_backspace: Option<bool>,
|
||||
|
||||
pub pre_paste_delay: Option<usize>,
|
||||
pub restore_clipboard_delay: Option<usize>,
|
||||
|
|
|
@ -88,6 +88,9 @@ pub(crate) struct YAMLConfig {
|
|||
#[serde(default)]
|
||||
pub search_shortcut: Option<String>,
|
||||
|
||||
#[serde(default)]
|
||||
pub undo_backspace: Option<bool>,
|
||||
|
||||
// Include/Exclude
|
||||
#[serde(default)]
|
||||
pub includes: Option<Vec<String>>,
|
||||
|
@ -163,6 +166,7 @@ impl TryFrom<YAMLConfig> for ParsedConfig {
|
|||
}),
|
||||
search_trigger: yaml_config.search_trigger,
|
||||
search_shortcut: yaml_config.search_shortcut,
|
||||
undo_backspace: yaml_config.undo_backspace,
|
||||
|
||||
pre_paste_delay: yaml_config.pre_paste_delay,
|
||||
restore_clipboard_delay: yaml_config.restore_clipboard_delay,
|
||||
|
@ -216,6 +220,7 @@ mod tests {
|
|||
options: test_options
|
||||
search_trigger: "search"
|
||||
search_shortcut: "CTRL+SPACE"
|
||||
undo_backspace: false
|
||||
|
||||
use_standard_includes: true
|
||||
includes: ["test1"]
|
||||
|
@ -261,6 +266,7 @@ mod tests {
|
|||
keyboard_layout: Some(keyboard_layout),
|
||||
search_trigger: Some("search".to_owned()),
|
||||
search_shortcut: Some("CTRL+SPACE".to_owned()),
|
||||
undo_backspace: Some(false),
|
||||
|
||||
pre_paste_delay: Some(300),
|
||||
|
||||
|
|
|
@ -290,6 +290,10 @@ impl Config for ResolvedConfig {
|
|||
None => Some("ALT+SPACE".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn undo_backspace(&self) -> bool {
|
||||
self.parsed.undo_backspace.unwrap_or(true)
|
||||
}
|
||||
}
|
||||
|
||||
impl ResolvedConfig {
|
||||
|
@ -365,6 +369,7 @@ impl ResolvedConfig {
|
|||
keyboard_layout,
|
||||
search_trigger,
|
||||
search_shortcut,
|
||||
undo_backspace,
|
||||
includes,
|
||||
excludes,
|
||||
extra_includes,
|
||||
|
|
|
@ -366,6 +366,10 @@ impl Config for LegacyInteropConfig {
|
|||
fn search_shortcut(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
fn undo_backspace(&self) -> bool {
|
||||
self.config.undo_backspace
|
||||
}
|
||||
}
|
||||
|
||||
struct LegacyMatchGroup {
|
||||
|
|
Loading…
Reference in New Issue
Block a user