Skip to content

Commit b75b76b

Browse files
committed
fix(vscode): further simplify path handling
1 parent e24c9da commit b75b76b

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

sqlmesh/lsp/uri.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ def __repr__(self) -> str:
2424

2525
def to_path(self) -> Path:
2626
p = to_fs_path(self.value)
27-
return Path(p)
27+
unencoded_path = p.replace("%3A", ":")
28+
return Path(unencoded_path)
2829

2930
@staticmethod
3031
def from_path(path: t.Union[str, Path]) -> "URI":
3132
if isinstance(path, Path):
32-
path = path.as_posix()
33-
return URI(from_fs_path(path))
33+
path = str(path)
34+
encoded_path = path.replace(":", "%3A")
35+
return URI(from_fs_path(encoded_path))

tests/lsp/test_context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ def test_lsp_context():
2020
# Check that the value is a ModelInfo with the expected model name
2121
assert isinstance(lsp_context.map[active_customers_key], ModelTarget)
2222
assert "sushi.active_customers" in lsp_context.map[active_customers_key].names
23+
24+
# Check that all the values in the map are normalised
25+
keys = lsp_context.map.keys()
26+
for key in keys:
27+
stripped_key_from_prefix = str(key).split("file://")[1]
28+
assert ":" not in stripped_key_from_prefix
29+
assert "\\" not in stripped_key_from_prefix

0 commit comments

Comments
 (0)