File tree Expand file tree Collapse file tree
crates/forge_main/src/zsh Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -426,6 +426,20 @@ mod tests {
426426 assert_eq ! ( actual, expected) ;
427427 }
428428
429+ /// Regression: forge keybindings must survive zsh-vi-mode's `zvm_init`
430+ /// by re-applying via `zvm_after_init_commands` (#2681).
431+ #[ test]
432+ fn test_generated_plugin_registers_zvm_after_init_hook ( ) {
433+ use pretty_assertions:: assert_eq;
434+
435+ let fixture = generate_zsh_plugin ( ) . unwrap ( ) ;
436+ let actual = fixture. contains ( "function _forge_apply_keybindings()" )
437+ && fixture. contains ( "typeset -ga zvm_after_init_commands" )
438+ && fixture. contains ( "zvm_after_init_commands+=('_forge_apply_keybindings')" ) ;
439+ let expected = true ;
440+ assert_eq ! ( actual, expected) ;
441+ }
442+
429443 #[ test]
430444 fn test_setup_zsh_integration_without_nerd_font_config ( ) {
431445 use tempfile:: TempDir ;
Original file line number Diff line number Diff line change @@ -35,11 +35,17 @@ function forge-bracketed-paste() {
3535 zle reset-prompt
3636}
3737
38- # Register the bracketed paste widget to fix highlighting on paste
39- zle -N bracketed-paste forge-bracketed-paste
38+ # Re-applied after zsh-vi-mode's `zvm_init` precmd hook, which rebuilds the
39+ # main/viins/vicmd keymaps and otherwise silently clobbers these bindings.
40+ function _forge_apply_keybindings() {
41+ zle -N bracketed-paste forge-bracketed-paste
42+ bindkey ' ^M' forge-accept-line
43+ bindkey ' ^J' forge-accept-line
44+ bindkey ' ^I' forge-completion
45+ }
46+
47+ _forge_apply_keybindings
4048
41- # Bind Enter to our custom accept-line that transforms :commands
42- bindkey ' ^M' forge-accept-line
43- bindkey ' ^J' forge-accept-line
44- # Update the Tab binding to use the new completion widget
45- bindkey ' ^I' forge-completion # Tab for both @ and :command completion
49+ # Harmless no-op when zsh-vi-mode (jeffreytse/zsh-vi-mode) isn't loaded.
50+ typeset -ga zvm_after_init_commands
51+ zvm_after_init_commands+=(' _forge_apply_keybindings' )
You can’t perform that action at this time.
0 commit comments