File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,8 +189,12 @@ def _(event):
189189 event .current_buffer .complete_state = None
190190 event .app .current_buffer .complete_state = None
191191
192- @kb .add ("c-space" )
193- def _ (event ):
192+ # Bind each key in toggle_completion_key to toggle completion.
193+ # Space-separated keys each get their own binding.
194+ # e.g., "c-space c-t" binds both Ctrl+Space and Ctrl+T independently.
195+ toggle_keys = pgcli .toggle_auto_completion_key .strip ().split ()
196+
197+ def _toggle_completion (event ):
194198 """
195199 Toggle autocompletion at cursor.
196200
@@ -199,16 +203,15 @@ def _(event):
199203
200204 If the menu is showing, close it (toggle off).
201205 """
202- _logger .debug ("Detected <C-Space> key." )
203-
204206 b = event .app .current_buffer
205207 if b .complete_state :
206- # Close completion menu (toggle off)
207208 b .complete_state = None
208209 else :
209- # Open completion menu (toggle on)
210210 b .start_completion (select_first = False )
211211
212+ for _key in toggle_keys :
213+ kb .add (_key )(_toggle_completion )
214+
212215 @kb .add ("c-j" , filter = has_completions )
213216 def _ (event ):
214217 """
Original file line number Diff line number Diff line change @@ -255,6 +255,9 @@ def __init__(
255255 self .column_date_formats = c ["column_date_formats" ]
256256 auth .keyring_initialize (c ["main" ].as_bool ("keyring" ), logger = self .logger )
257257 self .show_bottom_toolbar = c ["main" ].as_bool ("show_bottom_toolbar" )
258+ self .toggle_auto_completion_key = c ["main" ].get (
259+ "toggle_auto_completion_key" , "c-space"
260+ )
258261
259262 self .pgspecial .pset_pager (self .config ["main" ].as_bool ("enable_pager" ) and "on" or "off" )
260263
Original file line number Diff line number Diff line change @@ -154,6 +154,16 @@ syntax_style = default
154154# Ctrl+k - Navigate to previous completion (up) - Vim style
155155# Ctrl+p - Move up in history
156156# Ctrl+n - Move down in history
157+
158+ # Key binding for toggling the auto-completion menu on/off.
159+ # Uses prompt_toolkit key notation. Space-separated keys each
160+ # get their own independent binding. Examples:
161+ # c-space (Ctrl+Space - default)
162+ # c-t (Ctrl+T)
163+ # c-space c-t (both Ctrl+Space and Ctrl+T will toggle)
164+ # See prompt_toolkit docs for full key notation reference.
165+ toggle_auto_completion_key = c-space
166+
157167vi = False
158168
159169# Error handling
You can’t perform that action at this time.
0 commit comments