-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I have this .exs file
defmodule Bob do
import String
def hey(input) do
cond do
"" == trim(input) ->
"Fine. Be that way!"
ends_with?(input, "?") ->
"Sure."
input == upcase(input) && input != downcase(input) ->
"Whoa, chill out!"
true ->
"Whatever."
end
end
end
And in my keybindings I have
{"keys": ["ctrl+alt+/"], "command": "reindent", "args": {"single_line": false}},
But when I reident the file I get
defmodule Bob do
import String
def hey(input) do
cond do
"" == trim(input) ->
"Fine. Be that way!"
ends_with?(input, "?") ->
"Sure."
input == upcase(input) && input != downcase(input) ->
"Whoa, chill out!"
true ->
"Whatever."
end
end
end
This happens when the arrow ->
is at the end of the line. If the statement is in the same line then the code formatting works fine.
defmodule Bob do
import String
def hey(input) do
cond do
"" == trim(input) -> "Fine. Be that way!"
ends_with?(input, "?") -> "Sure."
input == upcase(input) && input != downcase(input) -> "Whoa, chill out!"
true -> "Whatever."
end
end
end
And here is an example what happens with a longer file.
defmodule BinarySearch do
@spec search(tuple, integer) :: {:ok, integer} | :not_found
def search(numbers, key) do
high = tuple_size(numbers) - 1
_search(numbers, key, 0, high)
end
defp _search(numbers, key, low, high) do
midpoint = low + div((high - low), 2)
cond do
low > high ->
:not_found
elem(numbers, midpoint) == key ->
{:ok, midpoint}
elem(numbers, midpoint) > key ->
_search(numbers, key, low, midpoint - 1)
elem(numbers, midpoint) < key ->
_search(numbers, key, midpoint + 1, high)
end
end
end
Metadata
Metadata
Assignees
Labels
No labels