Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
Make compatible with Sublime Text 3. Thanks to Alexander Danilenko fo…
Browse files Browse the repository at this point in the history
…r fix.
  • Loading branch information
Alexander Staubo committed Mar 15, 2013
1 parent 7c15269 commit 6c9d171
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions alternative_autocomplete.py
Expand Up @@ -53,8 +53,7 @@ def insert_completion(self, position, text, cycle, default):
if current_word in self.candidates:
self.candidates.remove(current_word)
if self.candidates:
edit = self.view.begin_edit()
self.view.erase(edit, sublime.Region(prefix_match.start(1), prefix_match.end(1)))
self.view.erase(self.edit, sublime.Region(prefix_match.start(1), prefix_match.end(1)))
if self.previous_completion is None:
completion = self.candidates[0]
else:
Expand All @@ -63,8 +62,7 @@ def insert_completion(self, position, text, cycle, default):
else:
direction = 1
completion = self.candidates[(self.candidates.index(self.previous_completion) + direction) % len(self.candidates)]
self.view.insert(edit, prefix_match.start(1), completion)
self.view.end_edit(edit)
self.view.insert(self.edit, prefix_match.start(1), completion)
self.previous_completion = completion
else:
if default and default != '':
Expand All @@ -78,7 +76,7 @@ def find_candidates(self, prefix, position, text):
if len(candidates) > 100:
break
if candidates:
candidates.sort(lambda a, b: cmp(a.distance, b.distance))
candidates.sort(key = lambda c: c.distance)
candidates = [candidate.text for candidate in candidates]
else:
word_regex = re.compile(r'\b' + re.escape(prefix[0:1]) + r'[\w\d]+', re.M | re.U | re.I)
Expand Down

0 comments on commit 6c9d171

Please sign in to comment.