aboutsummaryrefslogtreecommitdiff
path: root/src/app/state.rs
diff options
context:
space:
mode:
authorsf-jin-ku <jin.ku@sendbird.com>2026-06-03 09:13:01 -0700
committerGitHub <noreply@github.com>2026-06-03 19:13:01 +0300
commitf5e66b251fa8ec24989bf25861bcf4e38a561470 (patch)
tree3244ffd1af0054334f8fe65ddbb0ff6f5a809cd3 /src/app/state.rs
parent03f68b7275f07c98769bf699d2aa14805b921f8d (diff)
feat: switch input source during prefix mode (#434)
On macOS, opt-in under [experimental], temporarily switch the host input source to the current ASCII-capable layout while prefix mode is active so prefix commands register even when a CJK IME is composing, then restore the previous input source when prefix mode exits or is cancelled. No-op when the current source is already ASCII-capable, on non-macOS platforms, or when any input source call fails. Pane text input is unaffected. Also pin next_resize_poll in next_loop_deadline_includes_selection_autoscroll_deadline so the selection autoscroll deadline stays the earliest; the default resize poll could otherwise beat it and flake the assertion. refs #400 Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/state.rs')
-rw-r--r--src/app/state.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/app/state.rs b/src/app/state.rs
index dd1b167e..a25c7c5e 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -867,6 +867,34 @@ impl SettingsSection {
}
}
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) enum ExperimentSetting {
+ PaneHistory,
+ SwitchAsciiInputSourceInPrefix,
+}
+
+impl ExperimentSetting {
+ pub(crate) const ALL: [Self; 2] = [Self::PaneHistory, Self::SwitchAsciiInputSourceInPrefix];
+
+ pub(crate) fn label(self) -> &'static str {
+ match self {
+ Self::PaneHistory => "pane screen history",
+ Self::SwitchAsciiInputSourceInPrefix => {
+ "switch to ascii input source in prefix (macOS)"
+ }
+ }
+ }
+
+ pub(crate) fn enabled(self, state: &AppState) -> bool {
+ match self {
+ Self::PaneHistory => state.pane_history_persistence_enabled(),
+ Self::SwitchAsciiInputSourceInPrefix => {
+ state.switch_ascii_input_source_in_prefix_enabled()
+ }
+ }
+ }
+}
+
/// All built-in theme names in display order.
pub const THEME_NAMES: &[&str] = &[
"catppuccin",
@@ -1268,6 +1296,11 @@ pub struct AppState {
pub cjk_ime_agents: Vec<crate::detect::Agent>,
/// DECSCUSR shape parameter (1–6) for the IME anchor cursor.
pub cjk_ime_cursor_shape: u8,
+ /// While prefix mode is active, switch the macOS host input source to an
+ /// ASCII-capable layout so prefix commands register as ASCII even when a
+ /// CJK IME is active. macOS only; a no-op elsewhere. See
+ /// `[experimental] switch_ascii_input_source_in_prefix`.
+ pub switch_ascii_input_source_in_prefix: bool,
pub kitty_graphics_enabled: bool,
pub default_shell: String,
pub shell_mode: crate::config::ShellModeConfig,
@@ -1327,6 +1360,10 @@ impl AppState {
self.pane_history_persistence
}
+ pub fn switch_ascii_input_source_in_prefix_enabled(&self) -> bool {
+ self.switch_ascii_input_source_in_prefix
+ }
+
pub(crate) fn integration_updates_available(&self) -> bool {
self.integration_recommendations
.iter()
@@ -1575,6 +1612,7 @@ impl AppState {
cjk_ime_agent_filter_configured: false,
cjk_ime_agents: Vec::new(),
cjk_ime_cursor_shape: 2, // steady_block
+ switch_ascii_input_source_in_prefix: false,
kitty_graphics_enabled: false,
default_shell: String::new(),
shell_mode: crate::config::ShellModeConfig::Auto,