fix(bicep): replace LS completions entirely for version/param/param_value contexts
For specific LRU contexts (version, param, param_value), the Bicep LS was appending its own random/irrelevant completions alongside the LRU catalog items. The LS has no knowledge of the private ACR registry, so its suggestions in these positions are noise. Now the LS items are discarded entirely for these three contexts. LS items are still kept (below LRU items) for module_path and unknown contexts.
This commit is contained in:
@@ -202,14 +202,24 @@ def _inject_completions(msg: dict[str, Any], context: dict | None = None) -> byt
|
||||
lru_items = BicepModuleCatalog.as_completion_items()
|
||||
|
||||
if lru_items:
|
||||
for item in items:
|
||||
st = item.get("sortText", item.get("label", ""))
|
||||
item["sortText"] = f"1_az_{st}"
|
||||
if isinstance(result, list):
|
||||
msg["result"] = lru_items + items
|
||||
if ctx_type in ("version", "param", "param_value"):
|
||||
# Replace LS completions entirely — the Bicep LS doesn't know about
|
||||
# the private registry, so its suggestions here are noise/random.
|
||||
if isinstance(result, list):
|
||||
msg["result"] = lru_items
|
||||
else:
|
||||
result["items"] = lru_items
|
||||
result["isIncomplete"] = False
|
||||
else:
|
||||
result["items"] = lru_items + items
|
||||
result["isIncomplete"] = True
|
||||
# module_path / unknown: keep LS completions below ours
|
||||
for item in items:
|
||||
st = item.get("sortText", item.get("label", ""))
|
||||
item["sortText"] = f"1_az_{st}"
|
||||
if isinstance(result, list):
|
||||
msg["result"] = lru_items + items
|
||||
else:
|
||||
result["items"] = lru_items + items
|
||||
result["isIncomplete"] = True
|
||||
|
||||
return json.dumps(msg).encode()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user