|
| 1 | +from awsshell.fuzzy import fuzzy_search |
| 2 | + |
1 | 3 | EMPTY = {'arguments': [], 'commands': [], 'children': {}}
|
2 | 4 | import logging
|
3 | 5 | logging.basicConfig(filename='/tmp/completions', level=logging.DEBUG)
|
@@ -92,25 +94,8 @@ def autocomplete(self, line):
|
92 | 94 | # in either of the above two cases.
|
93 | 95 | return self._current['commands'][:]
|
94 | 96 | elif last_word.startswith('-'):
|
95 |
| - return self._autocomplete_options(last_word) |
96 |
| - return self._score(last_word, self._current['commands']) |
97 |
| - |
98 |
| - def _score(self, word, corpus): |
99 |
| - # This is a set of heuristics for what makes the |
100 |
| - # most sense to autocomplete. |
101 |
| - # The first thing are straight prefixes. If anything |
102 |
| - # you specify is an actual prefix, then we'll just |
103 |
| - # stick with that. |
104 |
| - # Note: I have a feeling I'll be messing with this |
105 |
| - # algorithm for a while. It might make sense to refactor |
106 |
| - # this out. |
107 |
| - prefix = [c for c in corpus if c.startswith(word)] |
108 |
| - if prefix: |
109 |
| - return prefix |
110 |
| - subsequence = [c for c in corpus if is_subsequence(word, c)] |
111 |
| - if subsequence: |
112 |
| - return subsequence |
113 |
| - return [] |
| 97 | + return fuzzy_search(last_word, self._current['arguments']) |
| 98 | + return fuzzy_search(last_word, self._current['commands']) |
114 | 99 |
|
115 | 100 | def _handle_backspace(self):
|
116 | 101 | return self._complete_from_full_parse()
|
|
0 commit comments