Skip to content

Commit

Permalink
Only filter candidate with prefix when incomplete-fuzzy-match is True.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Nov 3, 2023
1 parent 2b45302 commit 2679748
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/handler/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def process_response(self, response: dict) -> None:
if response is not None:
item_index = 0

# Get value of 'incomplete-fuzzy-match' from lsp server config file.
fuzzy = False
for server in self.file_action.get_match_lsp_servers("completion"):
if server.server_name.endswith("#" + self.method_server_name):
Expand All @@ -101,16 +102,18 @@ def process_response(self, response: dict) -> None:
display_new_text = True
break

print("!!!! ", response)
for item in response["items"] if "items" in response else response:
kind = KIND_MAP[item.get("kind", 0)].lower()
label = item["label"]
detail = item.get("detail", "")

# We always need filter label with input prefix and don't care isIncomplete whether is True or False.
# If some LSP server's `incomplete-fuzzy-match` option is True, we filter label with fuzzy algorithm.
if not string_match(label.lower(), self.prefix.lower(), fuzzy=fuzzy):
# NOTE:
# If lsp server contain 'incomplete-fuzzy-match' option and it's True, we filter 'label' with fuzzy algorithm.
# Otherwise, don't filter 'label' with 'prefix', such as we input "std::" in c++, all candidate's prefix is not "::"
if fuzzy and not string_match(label.lower(), self.prefix.lower(), fuzzy=fuzzy):
continue

annotation = kind if kind != "" else detail

# The key keyword combines the values ​​of 'label' and 'detail'
Expand Down

0 comments on commit 2679748

Please sign in to comment.