fix(bicep): detect param context when module ref has empty version
The lookback regex used ([^']+) requiring one or more version chars, so 'br/modules:modules/keyvault:' (no version yet) silently fell through to the unknown context and injected all module names instead of params. Change + to * to allow empty version string. The param_completion_items fallback already handles empty version by picking the closest schema.
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user