Skip to content

Commit

Permalink
DefinitionSummary: favor last hovered definition
Browse files Browse the repository at this point in the history
While there's an in-flight definition summary request, and the user
hovers over a new definition, discard the original one in favor of the
newly hovered definition.
  • Loading branch information
hojberg committed Dec 22, 2023
1 parent c2a77c1 commit 1d97e2c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Code/DefinitionSummaryTooltip.elm
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,28 @@ update config msg model =
( { model | activeTooltip = cached }, Cmd.none )

FetchDefinition ref ->
let
fetchDef =
( { model | activeTooltip = Just ( ref, Loading ) }
, fetchDefinition config ref |> HttpApi.perform config.api
)
in
case model.activeTooltip of
Just ( r, Loading ) ->
if Reference.equals ref r then
( model, Cmd.none )

else
-- If we've moved on to hovering over a different
-- definition while another was loading, discard the
-- original request
fetchDef

Just _ ->
( model, Cmd.none )

Nothing ->
( { model | activeTooltip = Just ( ref, Loading ) }
, fetchDefinition config ref |> HttpApi.perform config.api
)
fetchDef

HideTooltip _ ->
( { model | activeTooltip = Nothing }, Cmd.none )
Expand Down

0 comments on commit 1d97e2c

Please sign in to comment.