diff --git a/ilsp/bicep_lsp/proxy.py b/ilsp/bicep_lsp/proxy.py index f16ddfd..258b339 100644 --- a/ilsp/bicep_lsp/proxy.py +++ b/ilsp/bicep_lsp/proxy.py @@ -118,7 +118,7 @@ class _ProxySession: # Find the last module declaration in the lookback window mod_matches = list( - re.finditer(r"module\s+\w+\s+'br/modules:([^:]+):([^']+)'", context_text) + re.finditer(r"module\s+\w+\s+'br/modules:([^:]+):([^']*)'", context_text) ) if mod_matches: last_mod = mod_matches[-1] diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 5b16fdb..b68c056 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -253,6 +253,22 @@ def test_detect_param_context(): assert ctx["version"] == "1.1.x" +def test_detect_param_context_empty_version(): + """Params context should work even when module ref has no version yet.""" + lines = [ + "module keyVault 'br/modules:modules/keyvault:' = {", + " params: {", + " ", # ← cursor here + " }", + "}", + ] + session = _make_session_with_doc(URI, lines) + ctx = session._detect_context(URI, {"line": 2, "character": 4}) + assert ctx["type"] == "param" + assert ctx["module"] == "modules/keyvault" + assert ctx["version"] == "" + + def test_detect_param_value_context_no_quote(): """Cursor after 'principalType: ' (no opening quote) → param_value context.""" lines = [