@@ -62,7 +62,20 @@ func NewRootCmd() *cobra.Command {
6262 RunE : func (cmd * cobra.Command , args []string ) error {
6363 var opts command.Options
6464 var err error
65- var kb command.TUIKeyBindings
65+ // Default keybindings.
66+ var kb = command.TUIKeyBindings {
67+ RunQuery : tcell .KeyCtrlSpace ,
68+ Structure : tcell .KeyCtrlS ,
69+ Indexes : tcell .KeyCtrlI ,
70+ Constraints : tcell .KeyCtrlT ,
71+ ClearEditor : tcell .KeyCtrlD ,
72+ Navigation : command.TUINavigationBindgins {
73+ Up : tcell .KeyCtrlK ,
74+ Down : tcell .KeyCtrlJ ,
75+ Left : tcell .KeyCtrlH ,
76+ Right : tcell .KeyCtrlL ,
77+ },
78+ }
6679
6780 if cfg {
6881 opts , err = config .Init (cfgName )
@@ -100,33 +113,6 @@ func NewRootCmd() *cobra.Command {
100113 SSHKeyPassphrase : sshKeyPassphrase ,
101114 }
102115
103- // Default keybindings.
104- kb = command.TUIKeyBindings {
105- RunQuery : tcell .KeyCtrlSpace ,
106- Structure : tcell .KeyCtrlS ,
107- Indexes : tcell .KeyCtrlI ,
108- Constraints : tcell .KeyCtrlT ,
109- ClearEditor : tcell .KeyCtrlD ,
110- Navigation : command.TUINavigationBindgins {
111- Up : tcell .KeyCtrlK ,
112- Down : tcell .KeyCtrlJ ,
113- Left : tcell .KeyCtrlH ,
114- Right : tcell .KeyCtrlL ,
115- },
116- }
117-
118- // If the --keybindings flag is set, fill the keybindings with the ones fonud in the config file.
119- // This is safe to do even if they're missing in the config files, because the config package has default values for it.
120- if keybindings {
121- kb , err = config .SetupKeybindings ()
122- if err != nil {
123- return err
124- }
125- }
126-
127- // Set the keybindings values, either the default ones or the found in the config file.
128- opts .UpdateKeybindings (kb )
129-
130116 if form .IsEmpty (opts ) {
131117 opts , err = form .Run ()
132118 if err != nil {
@@ -135,6 +121,18 @@ func NewRootCmd() *cobra.Command {
135121 }
136122 }
137123
124+ // If the --keybindings flag is set, fill the keybindings with the ones fonud in the config file.
125+ // This is safe to do even if they're missing in the config files, because the config package has default values for it.
126+ if keybindings {
127+ kb , err = config .SetupKeybindings ()
128+ if err != nil {
129+ return err
130+ }
131+ }
132+
133+ // Set the keybindings values, either the default ones or the found in the config file.
134+ opts .UpdateKeybindings (kb )
135+
138136 if err := connection .ValidateOpts (opts ); err != nil {
139137 return err
140138 }
0 commit comments