Skip to content

Commit 2f16a23

Browse files
committed
Fix bug in doc delay
1 parent 2a23ad8 commit 2f16a23

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

awsshell/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
import tempfile
77
import subprocess
8+
import logging
89

910
from prompt_toolkit.document import Document
1011
from prompt_toolkit.shortcuts import create_eventloop
@@ -18,6 +19,9 @@
1819
from awsshell.ui import create_default_layout
1920

2021

22+
LOG = logging.getLogger(__name__)
23+
24+
2125
def create_aws_shell(completer, history, docs):
2226
return AWSShell(completer, history, docs)
2327

@@ -103,13 +107,9 @@ def on_input_timeout(self, cli):
103107
buffer = cli.current_buffer
104108
document = buffer.document
105109
text = document.text
110+
LOG.debug("document.text = %s", text)
111+
LOG.debug("current_command = %s", self.completer.current_command)
106112
if text.strip():
107-
# TODO: Big todo here. Relying on the completer
108-
# command means we're always "a step behind."
109-
# We don't pull up docs until you start typing
110-
# the next component :(
111-
# We need to hook into prompt_toolkits auto
112-
# completion event.
113113
command = self.completer.current_command
114114
key_name = '.'.join(command.split()).encode('utf-8')
115115
last_option = self.completer.last_option
@@ -122,6 +122,7 @@ def on_input_timeout(self, cli):
122122
self.current_docs = u''
123123
cli.buffers['clidocs'].reset(
124124
initial_document=Document(self.current_docs, cursor_position=0))
125+
cli.request_redraw()
125126

126127
def create_cli_interface(self):
127128
# A CommandLineInterface from prompt_toolkit

tests/test_completions.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,34 @@ def test_can_handle_skips_in_completion(index_data):
252252
c = completer.autocomplete
253253
result = c('ec2 create-ta')
254254
assert result == ['create-tags']
255+
256+
257+
def test_cmd_path_updated_on_completions(index_data):
258+
index_data['aws']['commands'] = ['ec2']
259+
index_data['aws']['children'] = {
260+
'ec2': {
261+
'commands': ['create-tags', 'describe-instances'],
262+
'argument_metadata': {},
263+
'arguments': [],
264+
'children': {
265+
'create-tags': {
266+
'commands': [],
267+
'argument_metadata': {
268+
'--resources': {'example': '', 'minidoc': 'foo'},
269+
'--tags': {'example': 'bar', 'minidoc': 'baz'},
270+
},
271+
'arguments': ['--resources', '--tags'],
272+
}
273+
}
274+
}
275+
}
276+
completer = AWSCLIModelCompleter(index_data)
277+
c = completer.autocomplete
278+
result = c('ec2 create-tags ')
279+
assert result == []
280+
assert completer.cmd_path == ['aws', 'ec2', 'create-tags']
281+
assert completer.arg_metadata == {
282+
'--resources': {'example': '', 'minidoc': 'foo'},
283+
'--tags': {'example': 'bar', 'minidoc': 'baz'},
284+
}
285+

0 commit comments

Comments
 (0)