fix(bicep): always suppress LS noise in version/param/param_value contexts
Previously the 'if lru_items:' guard meant that when our catalog returned an empty list (e.g. a param with no allowed enum values), the Bicep LS completions (Bicep keywords, schema types) would leak through unchanged. Now the replace is unconditional for version/param/param_value contexts. The Bicep LS has no knowledge of our private ACR registry so its output in these positions is always noise — suppress it even when we have nothing better to show.
This commit is contained in:
@@ -201,25 +201,25 @@ def _inject_completions(msg: dict[str, Any], context: dict | None = None) -> byt
|
||||
# Default: module name completions
|
||||
lru_items = BicepModuleCatalog.as_completion_items()
|
||||
|
||||
if lru_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
|
||||
if ctx_type in ("version", "param", "param_value"):
|
||||
# Always replace LS completions for private-registry contexts — the
|
||||
# Bicep LS doesn't know about our ACR, so anything it returns is noise.
|
||||
# Even if lru_items is empty (no enum values for a param), suppress LS.
|
||||
if isinstance(result, list):
|
||||
msg["result"] = lru_items
|
||||
else:
|
||||
# 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
|
||||
result["items"] = lru_items
|
||||
result["isIncomplete"] = False
|
||||
elif lru_items:
|
||||
# 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