Skip to content

Commit

Permalink
Force abbreviation suggest on explicit action
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Oct 26, 2020
1 parent d26b5bc commit cb37b4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/abbreviation.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ def at_word_bound(editor: sublime.View, r: sublime.Region) -> bool:
return not ch or re_bound_char.match(ch)


def suggest_abbreviation_tracker(view: sublime.View, pos: int) -> AbbreviationTracker:
def suggest_abbreviation_tracker(view: sublime.View, pos: int, force = False) -> AbbreviationTracker:
"Tries to extract abbreviation from given position and returns tracker for it, if available"
trk = get_tracker(view)
if trk and not trk.region.contains(pos):
stop_tracking(view)
trk = None

if not trk and allow_tracking(view, pos):
if not trk and (force or allow_tracking(view, pos)):
# Try to extract abbreviation from current location
config = get_activation_context(view, pos)
if config:
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def single_caret(self, edit, tab=False):
if not trk and not tab:
# No active tracker but we are expanding not from Tab:
# try to create tracker from current location
trk = abbreviation.suggest_abbreviation_tracker(self.view, caret)
trk = abbreviation.suggest_abbreviation_tracker(self.view, caret, True)

if trk and trk.region.contains(caret):
abbreviation.expand_tracker(self.view, edit, trk)
Expand Down

0 comments on commit cb37b4e

Please sign in to comment.