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
|
# 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"):
|
# Always replace LS completions for private-registry contexts — the
|
||||||
# Replace LS completions entirely — the Bicep LS doesn't know about
|
# Bicep LS doesn't know about our ACR, so anything it returns is noise.
|
||||||
# the private registry, so its suggestions here are noise/random.
|
# 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:
|
|
||||||
result["items"] = lru_items
|
|
||||||
result["isIncomplete"] = False
|
|
||||||
else:
|
else:
|
||||||
# module_path / unknown: keep LS completions below ours
|
result["items"] = lru_items
|
||||||
for item in items:
|
result["isIncomplete"] = False
|
||||||
st = item.get("sortText", item.get("label", ""))
|
elif lru_items:
|
||||||
item["sortText"] = f"1_az_{st}"
|
# module_path / unknown: keep LS completions below ours
|
||||||
if isinstance(result, list):
|
for item in items:
|
||||||
msg["result"] = lru_items + items
|
st = item.get("sortText", item.get("label", ""))
|
||||||
else:
|
item["sortText"] = f"1_az_{st}"
|
||||||
result["items"] = lru_items + items
|
if isinstance(result, list):
|
||||||
result["isIncomplete"] = True
|
msg["result"] = lru_items + items
|
||||||
|
else:
|
||||||
|
result["items"] = lru_items + items
|
||||||
|
result["isIncomplete"] = True
|
||||||
|
|
||||||
return json.dumps(msg).encode()
|
return json.dumps(msg).encode()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user