halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Add import does not add import #65

Closed pacbeckh closed 7 years ago

pacbeckh commented 7 years ago

Given the following file:

module Foo (selectEventHandler)

import Json.Decode as Json
import Html.Events.Extra exposing (targetSelectedIndex)
import Html.Events exposing (on)

selectEventHandler : (Maybe Int -> msg) -> Html.Attribute msg
selectEventHandler onSelect =
    on "change" (Json.map onSelect targetSelectedIndex)

An import is suggested for Html.Attribute. Nothing happens when Add Import is executed: ScreenCapture

halohalospecial commented 7 years ago

@pacbeckh, thanks for the report!

I noticed there's a syntax error: module Foo (selectEventHandler) should be module Foo exposing (selectEventHandler)

When I added " exposing ", Add Import worked as usual. I have to investigate further.

pacbeckh commented 7 years ago

I managed to reduce the problem to:

module Foo exposing (..)

import Json.Decode
import Html.Events

selectEventHandler : (Maybe Int -> msg) -> Html.Attribute msg
selectEventHandler onSelect =
    Html.Events.on "change" (Json.Decode.fail "")

It seems that if import Html.Events import is already present, it cannot also add import Html

Demo: ScreenCapture

Also tested by @stil4m

halohalospecial commented 7 years ago

Hmm, weird that it's working on my computer :thinking:

add-import-issue

halohalospecial commented 7 years ago

Oh! You're using the Quick Fix command of linter-elm-make. It does not have information about the imports. Let's move this issue there.

pacbeckh commented 7 years ago

@halohalospecial , it is indeed the Quick Fix command. I should have made that more clear.

It does work if import Html.Event is removed.