Skip to content

Commit

Permalink
Tab press on an empty line is interrupted as a \t character insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Balabanov committed Jul 27, 2018
1 parent f12b472 commit 205949a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pgcli/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ def _(event):
"""
_logger.debug('Detected <Tab> key.')
b = event.cli.current_buffer
if b.complete_state:
b.complete_next()

line_start = b.document.cursor_position + b.document.get_start_of_line_position()
line_end = b.document.cursor_position + b.document.get_end_of_line_position()
current_line = b.document.text[line_start:line_end]

if current_line.strip():
if b.complete_state:
b.complete_next()
else:
event.cli.start_completion(select_first=True)
else:
event.cli.start_completion(select_first=True)
b.insert_text('\t', fire_event=False)

@key_binding_manager.registry.add_binding(Keys.ControlSpace)
def _(event):
Expand Down

0 comments on commit 205949a

Please sign in to comment.