diff --git a/ilsp/bicep_lsp/proxy.py b/ilsp/bicep_lsp/proxy.py index c691bad..f16ddfd 100644 --- a/ilsp/bicep_lsp/proxy.py +++ b/ilsp/bicep_lsp/proxy.py @@ -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() diff --git a/tests/test_proxy.py b/tests/test_proxy.py index fff9e32..5b16fdb 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -102,9 +102,9 @@ def test_version_completions_injected_on_version_context(): assert "1.1.x" in labels assert "2.0.x" in labels assert "latest" in labels - # LRU versions come first - assert items[0]["sortText"].startswith("0_lru_ver_") - assert items[-1]["sortText"].startswith("1_az_") + # LS items are replaced entirely — private registry versions only + assert all(i["sortText"].startswith("0_lru_ver_") for i in items) + assert not any(i["label"] == "az-builtin" for i in items) def test_version_items_include_param_detail(): @@ -366,9 +366,8 @@ def test_param_value_injected_in_completion_response(): "param": "environmentType", "has_open_quote": False} out = json.loads(_inject_completions(msg, ctx)) labels = [i["label"] for i in out["result"]["items"]] - # LRU enum values should be first - assert labels[:3] == ["DEV", "TEST", "PROD"] - assert "existing" in labels + # LRU enum values only — LS completions are replaced entirely + assert labels == ["DEV", "TEST", "PROD"] def test_detect_unknown_context_outside_module():