fix: make Right Arrow configurable and correct overlay positioning (#110)
## Summary Closes #108 This PR fixes two issues related to terminal interaction and rendering: - Make Right Arrow ghost acceptance configurable instead of hard-coded. - Correct overlay positioning when the shell prompt wraps across terminal lines. ## Changes ### Right Arrow configuration - Add a new `navigate-right` keybinding to the configuration. - Add `navigate-right = "right"` to the default configuration to preserve existing behavior. - Update the wrapper to use the configured binding instead of a hard-coded Right Arrow check. - Forward the Right Arrow escape sequence to the PTY when `navigate-right` is unset, allowing the shell or terminal to handle it normally. ### Overlay positioning - Compute the cursor's current column from the total visual width instead of using the accumulated width directly. - Correctly handle wrapped prompts by calculating the cursor column modulo the terminal width. - Clamp the overlay position so it never extends beyond the terminal width. - Extend debug logging with the computed cursor position to aid troubleshooting. ## Why Right Arrow ghost acceptance was previously implemented as a hard-coded behavior, making it impossible to disable or remap through configuration. This change makes it consistent with the existing configurable keybindings while preserving the default behavior. Overlay positioning assumed that the prompt length represented the cursor's current column. When the prompt wrapped onto a new terminal line, this assumption caused the suggestion overlay to be positioned incorrectly. Computing the cursor column from the wrapped position ensures the overlay is aligned with the actual cursor. ## Testing - [x] Default configuration retains Right Arrow ghost acceptance. - [x] Setting `navigate-right = ""` forwards Right Arrow to the shell. - [x] Existing keybindings continue to function as before. - [x] Overlay is correctly positioned for both short and wrapped prompts. - [x] Overlay remains within terminal bounds.
This commit is contained in:
@@ -69,6 +69,7 @@ type KeybindingsConfig struct {
|
||||
SelectSuggestion string `toml:"select"`
|
||||
NavigateUp string `toml:"navigate-up"`
|
||||
NavigateDown string `toml:"navigate-down"`
|
||||
NavigateRight string `toml:"navigate-right"`
|
||||
}
|
||||
|
||||
type SuggestOnEmptyConfig struct {
|
||||
@@ -207,6 +208,9 @@ func Load() (*Config, error) {
|
||||
if cfg.Keybindings.NavigateDown == "" {
|
||||
cfg.Keybindings.NavigateDown = "down"
|
||||
}
|
||||
if cfg.Keybindings.NavigateRight == "" {
|
||||
cfg.Keybindings.NavigateRight = "right"
|
||||
}
|
||||
|
||||
if err := validate(cfg); err != nil {
|
||||
return cfg, fmt.Errorf("config: invalid value: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user