Skip to content

Commit 3a185d8

Browse files
committed
Correctly fetch definitions via workspace
1 parent f14124a commit 3a185d8

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

elm-git.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"git-dependencies": {
33
"direct": {
4-
"https://github.com/unisonweb/ui-core": "73ffa9d42290ce3d5deeb80acc19f4606b2f7685"
4+
"https://github.com/unisonweb/ui-core": "7d8d5f9ee2e6de17f385e1ce90e87cc5b60e9c6e"
55
},
66
"indirect": {}
77
}

src/UnisonLocal/Api.elm

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,26 @@ codebaseApiEndpointToEndpoint cbEndpoint =
8181

8282
CodebaseApi.Definition { perspective, ref } ->
8383
let
84-
re =
85-
Maybe.withDefault Regex.never (Regex.fromString "#[d|a|](\\d+)$")
84+
constructorSuffixRegex =
85+
Maybe.withDefault Regex.never (Regex.fromString "#[ad]\\d$")
8686

87-
stripConstructorPositionFromHash =
88-
Regex.replace re (always "")
87+
withoutConstructorSuffix h =
88+
h
89+
|> Hash.toString
90+
|> Regex.replace constructorSuffixRegex (always "")
91+
92+
refToString r =
93+
case Reference.hashQualified r of
94+
HQ.NameOnly fqn ->
95+
FQN.toApiUrlString fqn
96+
97+
HQ.HashOnly h ->
98+
withoutConstructorSuffix h
99+
100+
HQ.HashQualified _ h ->
101+
withoutConstructorSuffix h
89102
in
90-
[ Reference.toApiUrlString ref ]
91-
|> List.map stripConstructorPositionFromHash
103+
[ refToString ref ]
92104
|> List.map (string "names")
93105
|> (\names -> GET { path = [ "getDefinition" ], queryParams = names ++ perspectiveToQueryParams perspective })
94106

0 commit comments

Comments
 (0)