Ctrl+Space の全角スペース入力を config.toml で切替可能にする - #39
Open
asonas wants to merge 8 commits into
Open
Conversation
Defines the design for making Ctrl+Space behavior configurable via config.toml. Currently hardcoded to intercept Ctrl+Space for full-width space input, preventing OS shortcuts from triggering. This spec allows users to disable the interception while maintaining backward compatibility with existing behavior as the default.
This plan outlines a TDD-driven implementation to make Ctrl+Space behavior configurable via config.toml. Users can choose whether Ctrl+Space inputs a full-width space (current behavior, kept as default) or passes through to the OS for window-switching and other shortcuts. The implementation adds a single boolean flag through the existing settings propagation path: config.toml → Settings → EngineConfig → engine key handling. Tasks cover settings struct, config mapping, and key processing in Empty and Composing states, with comprehensive test cases for both enabled and disabled modes.
Introduce a new [keys] configuration section that allows users to control whether Ctrl+Space inputs a full-width space (U+3000) or passes through to the OS for system shortcuts like window switching. The new ctrl_space_fullwidth setting defaults to true (current behavior) but can be set to false in config.toml to restore OS-level Ctrl+Space handling on macOS and Linux. This gives users full control over key interception without requiring code changes or rebuilds.
Add a new ctrl_space_fullwidth configuration to EngineConfig that controls whether Ctrl+Space inputs a full-width space (U+3000). When false, Ctrl+Space passes through to the OS without being consumed by the engine. The setting defaults to true and can be customized via the Settings structure. Include tests to verify the default value and that the setting correctly maps from user configuration.
When ctrl_space_fullwidth is false, Ctrl+Space key presses are not consumed and pass through to the OS, allowing window-switching shortcuts and other keybindings to function normally. Add tests to verify behavior in both enabled and disabled states: - ctrl_space_inputs_fullwidth_space_in_empty_when_enabled - ctrl_space_passes_through_in_empty_when_disabled
Make the Ctrl+Space full-width space insertion configurable via the `ctrl_space_fullwidth` setting. When disabled, Ctrl+Space passes through to the OS instead of being consumed by the engine. This prevents the fall-through bug where Ctrl+Space would trigger conversion mode if the bare-Space handler were to execute. An explicit return statement ensures correct control flow regardless of the config setting. Add tests to verify both enabled and disabled behavior while composing.
Clarify that the ctrl_space_fullwidth configuration only applies to Empty and Composing states. In Conversion state, Ctrl+Space always navigates to the next candidate regardless of the configuration, maintaining consistency with existing Space behavior and recognizing that window switching while viewing candidates is rare.
asonas
force-pushed
the
feature/configurable-ctrl-space
branch
from
August 8, 2026 08:37
32dd3e4 to
727c658
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Ctrl+Space を全角スペース (U+3000) 入力に使うかどうかを
config.tomlで切り替えられるようにします。これまで Ctrl+Space は Karukan が消費して全角スペースを入力していました。そのため、ユーザーが OS 側に割り当てた Ctrl+Space ショートカットが発火せず、代わりに全角スペースが入ってしまっていました。本 PR で
keys.ctrl_space_fullwidth = falseを設定すると、Karukan は Ctrl+Space を消費せず OS へ素通しするようになります。背景
config.tomlの手編集で行います。この Ctrl+Space の挙動もハードコードされており、変更できませんでした。process_key_empty) と入力中 (Composing,process_key_composing) です。いずれもconsumedを返すため、フロントがキーを飲み込み OS に届きませんでした。変更内容
karukan-im/config/default.toml: 新セクション[keys]とctrl_space_fullwidth(デフォルトtrue)を追加します。karukan-im/src/config/settings.rs:KeysSettings構造体とSettings.keysフィールドを追加します。ユーザー設定に[keys]が無い場合も、既存のmerge_tomlでデフォルトが埋まります。karukan-im/src/core/engine/types.rs:EngineConfigにctrl_space_fullwidth: boolを追加し、from_settings(設定から反映)とDefault(true)に反映します。karukan-im/src/core/engine/input.rs: Empty / Composing 両状態の Ctrl+Space 分岐に flag チェックを追加します。falseのときはnot_consumedを返して OS へ素通しします。Composing 側は変換トリガーへのフォールスルーを防ぐため、明示的にnot_consumedを返します。not_consumedを返せばフロント(macOS Swift / Linux fcitx5)が自動で OS へキーを渡すため、フロントエンド (Swift / C++) は無変更で macOS / Linux 両対応となります。挙動
ctrl_space_fullwidthtrue(デフォルト・従来通り)falseデフォルトは
trueのため、既存ユーザーの挙動は変わりません(後方互換です)。スコープ外(意図的)
候補ウィンドウ表示中(Conversion 状態)の Ctrl+Space は、
ctrl_space_fullwidthの値によらず従来通り「次の候補へ」として消費されます。候補表示中のウインドウ切替は稀であり、既存の bare-Space の候補送り挙動と揃える意図で、今回の設定対象外としています(設計 spec に明記しています)。テスト
karukan-imの全テスト 227 件が pass し、cargo clippy/cargo fmt --checkもクリーンです。[keys]のデフォルト値、falseオーバーライド、未指定セクションのデフォルト維持EngineConfigのデフォルトtrue、from_settingsマッピング