Skip to content

Commit

Permalink
dealing with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
seperman committed Jan 16, 2019
1 parent 23430cb commit 547b6c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fast_autocomplete/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = '0.2.2'
__version__ = '0.2.3'
import sys
pyversion = float(sys.version[:3])
if pyversion < 3.6:
Expand Down
8 changes: 6 additions & 2 deletions fast_autocomplete/dwg.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@ def _prefix_autofill_part(self, word, node=None, matched_condition_ever=False, m

if node.children:
if char not in node.children:
que.appendleft(char)
break
space_child = node.children.get(' ')
if space_child and char in space_child.children:
node = space_child
else:
que.appendleft(char)
break
node = node.children[char]
if char != ' ' or matched_prefix_of_last_word:
matched_prefix_of_last_word += char
Expand Down
7 changes: 7 additions & 0 deletions tests/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ def test_search_without_synonyms(self, word, max_cost, size, expected_results):
'expected_steps': STEP_DESCENDANTS_ONLY,
'expected_find_and_sort_results': [['truck']],
},
{'word': '1se',
'max_cost': 3,
'size': 5,
'expected_find_results': {1: [['1 series']]},
'expected_steps': STEP_DESCENDANTS_ONLY,
'expected_find_and_sort_results': [['1 series']],
},
]


Expand Down

0 comments on commit 547b6c3

Please sign in to comment.