Skip to content

Commit

Permalink
Merge pull request #29 from mateusfpleite/main
Browse files Browse the repository at this point in the history
fix: infinite loop when installing new function
  • Loading branch information
jxxcarlson authored Jun 18, 2024
2 parents 211ad0e + f3e2b2c commit e4289e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
8 changes: 7 additions & 1 deletion src/Install/Function.elm
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,14 @@ declarationVisitor context (Config config) declaration =
(Install.Library.getExpressionFromString context confg.functionImplementation)
== Just Normalize.ConfirmedEquality
|> not

isImplemented =
not (isNotImplemented function config)
in
if name == config.functionName && isInCorrectModule && isNotImplemented function config then
if isImplemented then
( [], { contextWithLastDeclarationRange | appliedFix = True } )

else if name == config.functionName && isInCorrectModule && isNotImplemented function config then
replaceFunction { range = Node.range declaration, functionName = config.functionName, functionImplementation = config.functionImplementation } context

else
Expand Down
30 changes: 0 additions & 30 deletions tests/Install/FunctionTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,3 @@ test4c =
, fixed = fixed4b
, message = "Add function \"newFunction\""
}


rule4c : Rule
rule4c =
Install.Function.init
"Frontend.Utilities"
"newFunction"
"""newFunction model =
Html.text "This is a test\""""
|> Install.Function.withInsertAfter "Model"
|> Install.Function.makeRule
under4c : String
under4c =
"""type alias Model =
{counter : Int}"""
fixed4c : String
fixed4c =
"""module Frontend.Utilities exposing(..)

import Html exposing (Html)
import Html.Attributes exposing (class)

type alias Model =
{counter : Int}
newFunction model =
Html.text "This is a test\""""

0 comments on commit e4289e7

Please sign in to comment.