wkirschbaum / elixir-ts-mode

Elixir mode using Treesitter for fontification, navigation and indentation
GNU General Public License v3.0
61 stars 11 forks source link

Weird indentation for empty tuples #11

Closed hochata closed 1 year ago

hochata commented 1 year ago

When typing a tuple in multiples lines, the indentation initially looks like this

  {
|
  }

But if you start typing anything, it gets properly indented

  {
    e|
  }

For contrast, inside both list and maps you get the second example indentation without the need to type anything.

wkirschbaum commented 1 year ago

thanks for logging this @hochata. i will have a look at this later today.

wkirschbaum commented 1 year ago

@hochata This issue should be fixed for most of the scenarios. I had to regress on other indentation issues, but think they were more of an edge case and this is more important. Please let me know if the latest change fixes your issue.

hochata commented 1 year ago

Hi, sorry for the late response.

It is still present on the main branch, and I also noticed it happens with parenthesis.

For example, a function call with no arguments gets indented like this

  func(
|
  )

But if you start typing some arguments it gets correctly fixed

  func(
    arg|
  )

But I think it is a pretty minor bug. It doesn't affect usability that much, it is just annoying.

wkirschbaum commented 1 year ago

@hochata i will continue to tweak, but there are some limitations from the elixir tree sitter grammar where we don't always know the parent of the function, so it looks at the source node ( main node ).

It is strange that you still get it for tuples though. Will have a further look.

Lets leave this open.

hochata commented 1 year ago

My bad @wkirschbaum , I think I was running an older versions without noticing it.

As you pointed out, this is solved for tuples in main!

Should I keep this open for the function calls case? Or maybe tag it as treesit-grammar-limitation and close it?

hochata commented 1 year ago

Thinking about it, even if an issue regarding the tree-sitter grammar limitation stays open, it should be a new dedicated issue.

Thanks for solving this!