Skip to content

Commit 48de894

Browse files
committed
Merge pull request #171 from Microsoft/fixCompletionIssue170
Fix completion issue 170 plus one more
2 parents f9c2bed + f4b5ee5 commit 48de894

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

TypeScript.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def __init__(self):
510510
self.fileMap = {}
511511
self.pendingCompletions = []
512512
self.completionsReady = False
513+
self.completionsLoc = None
513514
self.completionView = None
514515
self.mruFileList = []
515516
self.pendingTimeout = 0
@@ -520,6 +521,7 @@ def __init__(self):
520521
self.about_to_close_all = False
521522
self.was_paren_pressed = False
522523

524+
523525
def getInfo(self, view):
524526
info = None
525527
if view.file_name() is not None:
@@ -830,6 +832,9 @@ def on_selection_modified(self, view):
830832
# on_modified) what was inserted
831833
info.prevSel = copyRegionsStatic(view.sel())
832834
if self.mod:
835+
# backspace past start of completion
836+
if info.lastCompletionLoc and (info.lastCompletionLoc > view.sel()[0].begin()):
837+
view.run_command('hide_auto_complete')
833838
self.setOnSelectionIdleTimer(1250)
834839
else:
835840
self.setOnSelectionIdleTimer(50)
@@ -990,7 +995,7 @@ def on_query_completions(self, view, prefix, locations):
990995
view.add_regions("apresComp", decrLocsToRegions(locations, 0), flags=sublime.HIDDEN)
991996
if (not self.completionsReady) or cli.ST2():
992997
if info.lastCompletionLoc:
993-
if (((len(prefix)-1)+info.lastCompletionLoc == locations[0]) and (prefix.startswith(info.lastCompletionPrefix))):
998+
if ((len(prefix) > 0) and ((len(prefix)-1)+info.lastCompletionLoc == locations[0]) and (prefix.startswith(info.lastCompletionPrefix))):
994999
return (info.lastCompletions,
9951000
sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
9961001

@@ -1001,9 +1006,9 @@ def on_query_completions(self, view, prefix, locations):
10011006
else:
10021007
cli.service.asyncCompletions(view.file_name(), location, prefix, self.handleCompletionInfo)
10031008
completions = self.pendingCompletions
1009+
info.lastCompletionLoc = locations[0]
10041010
if self.completionsReady:
10051011
info.lastCompletions = completions
1006-
info.lastCompletionLoc = locations[0]
10071012
info.lastCompletionPrefix = prefix
10081013
self.pendingCompletions = []
10091014
self.completionsReady = False

libs/serviceproxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def completions(self, path, location=Location(1, 1), prefix="", on_completed=Non
4545
args = {"file": path, "line": location.line, "offset": location.offset, "prefix": prefix}
4646
req_dict = self.create_req_dict("completions", args)
4747
json_str = jsonhelpers.encode(req_dict)
48-
self.__comm.sendCmdAsync(
48+
self.__comm.sendCmd(
49+
lambda json_dict: None if on_completed is None else on_completed(json_dict),
4950
json_str,
50-
req_dict["seq"],
51-
lambda response_dict: None if on_completed is None else on_completed(response_dict),
51+
req_dict["seq"]
5252
)
5353

5454
def asyncCompletions(self, path, location=Location(1, 1), prefix="", on_completed=None):

0 commit comments

Comments
 (0)