elixir-editors / language-elixir

Elixir language support for the Atom editor.
Other
181 stars 40 forks source link

Lines -> Auto Indent (editor:auto-indent) misinterprets end) #18

Closed jamesjahraus closed 8 years ago

jamesjahraus commented 9 years ago

When end) it is interpreted as the end of the function, and incorrectly formats the module.

Example from: https://howistart.org/posts/elixir/1

Lines -> Auto Indent (editor:auto-indent)

defmodule Portal.Door do ... -- def pop(door) do ---- Agent.get_and_update(door, fn ---- [] -> {:error, []} ---- [h|t] -> {{:ok, h}, t} ---- end) end end

The auto-indent interprets end) as end for def pop.

Expected the auto-indent interprets end) as end for Agent.get_and_update:

defmodule Portal.Door do ... --def pop(door) do ---- Agent.get_and_update(door, fn ---- [] -> {:error, []} ---- [h|t] -> {{:ok, h}, t} ---- end) --end end

keathley commented 8 years ago

The issue that is the [] -> {:error, []} and [h|t] -> {{:ok, h}, t} aren't indented for that update code block. When you add the end it moves back a line. Since both of those function definitions are inside of the agent function then conventionally they should be indented anyway.

I've created a fix for this in #32