Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Further tab completion tweaks
  • Loading branch information
inducer committed Feb 1, 2014
1 parent 260f8b3 commit 407b491
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pudb/debugger.py
Expand Up @@ -1329,8 +1329,22 @@ def cmdline_tab_complete(w, size, key):

text = self.cmdline_edit.edit_text
pos = self.cmdline_edit.edit_pos

chopped_text = text[:pos]
remainder_text = text[pos:]
suffix = text[pos:]

# stolen from readline in the Python interactive shell
delimiters = " \t\n`~!@#$%^&*()-=+[{]}\\|;:\'\",<>/?"

complete_start_index = max(
chopped_text.rfind(delim_i)
for delim_i in delimiters)

if complete_start_index == -1:
prefix = ""
else:
prefix = chopped_text[:complete_start_index+1]
chopped_text = chopped_text[complete_start_index+1:]

state = 0
chopped_completions = []
Expand Down Expand Up @@ -1364,15 +1378,17 @@ def common_prefix(a, b):
if completed_chopped_text is None:
return

if len(completed_chopped_text) == pos and len(chopped_completions) > 1:
if (
len(completed_chopped_text) == len(chopped_text)
and len(chopped_completions) > 1):
add_cmdline_content(
" ".join(chopped_completions),
"command line output")
return

self.cmdline_edit.edit_text = \
completed_chopped_text+remainder_text
self.cmdline_edit.edit_pos = len(completed_chopped_text)
prefix+completed_chopped_text+suffix
self.cmdline_edit.edit_pos = len(prefix) + len(completed_chopped_text)

def cmdline_append_newline(w, size, key):
self.cmdline_edit.insert_text("\n")
Expand Down

0 comments on commit 407b491

Please sign in to comment.