Skip to content

Commit

Permalink
Don't cache empty completions response at some locations
Browse files Browse the repository at this point in the history
Eg. intelephense waits for 1 char before returning completions?
Fixes #745
  • Loading branch information
tomv564 committed Oct 10, 2019
1 parent df3d4d6 commit 4f9c91c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ def is_same_completion(self, prefix: str, locations: 'List[int]') -> bool:
if self.last_location < 0:
return False

# issue 745, some servers return nothing until some chars into a word are returned
# Don't cache these empty responses.
if prefix and self.last_prefix == "" and not self.completions:
return False

# completion requests from the same location with the same prefix are cached.
current_start = locations[0] - len(prefix)
last_start = self.last_location - len(self.last_prefix)
Expand Down
4 changes: 2 additions & 2 deletions plugin/core/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def text_edit_text(item: dict, word_col: int) -> 'Optional[str]':
if edit_range and edit_text:
edit_range = Range.from_lsp(edit_range)

debug('textEdit from col {}, {} applied at col {}'.format(
edit_range.start.col, edit_range.end.col, word_col))
# debug('textEdit from col {}, {} applied at col {}'.format(
# edit_range.start.col, edit_range.end.col, word_col))

if edit_range.start.col <= word_col:
# if edit starts at current word, we can use it.
Expand Down

0 comments on commit 4f9c91c

Please sign in to comment.