Skip to content

[Sublime Text 3] Arrows break indentation #133

Description

@voger

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions