fix(bicep): always suppress LS noise in version/param/param_value contexts
All checks were successful
Build and Deploy iLSP / test (push) Successful in 22s
Build and Deploy iLSP / build-and-deploy (push) Successful in 1m31s

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:
Henrik Jess Nielsen
2026-05-11 11:37:50 +02:00
parent 445ccb5769
commit 02c09f1d18

View File

@@ -201,16 +201,16 @@ def _inject_completions(msg: dict[str, Any], context: dict | None = None) -> byt
# Default: module name completions # Default: module name completions
lru_items = BicepModuleCatalog.as_completion_items() lru_items = BicepModuleCatalog.as_completion_items()
if lru_items:
if ctx_type in ("version", "param", "param_value"): if ctx_type in ("version", "param", "param_value"):
# Replace LS completions entirely — the Bicep LS doesn't know about # Always replace LS completions for private-registry contexts — the
# the private registry, so its suggestions here are noise/random. # 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): if isinstance(result, list):
msg["result"] = lru_items msg["result"] = lru_items
else: else:
result["items"] = lru_items result["items"] = lru_items
result["isIncomplete"] = False result["isIncomplete"] = False
else: elif lru_items:
# module_path / unknown: keep LS completions below ours # module_path / unknown: keep LS completions below ours
for item in items: for item in items:
st = item.get("sortText", item.get("label", "")) st = item.get("sortText", item.get("label", ""))