elixir-editors / elixir-editors/elixir-tmbundle
[Sublime Text 3] Arrows break indentation
- Dominant language
- Python
- Stars
- 262
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
I have this .exs file
```elixir
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
```elixir
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.
```elixir
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.
```elixir
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
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.