Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do-block inside if/then confuses indentation of else block #127

Open
DestyNova opened this issue Aug 2, 2021 · 2 comments
Open

do-block inside if/then confuses indentation of else block #127

DestyNova opened this issue Aug 2, 2021 · 2 comments

Comments

@DestyNova
Copy link

I typed in this example:

main = do
  let n = 1

  if n > 0
     then do
       print 1
       else print 2

The else is indented too far and should be directly under the then. If I use << to unindent the else line, it only moves left by one space and I have to manually delete a space from the beginning of the line.
I'm not sure if there's a specific interaction between the do and the if-then-else.

However, another example shows if the else block doesn't immediately follow on the next line from the then, it doesn't indent properly. If I hit enter after the then, the cursor lines up at the same level as then. Hitting tab inserts a single space, then I type the number 123, hit enter and type else, which lines up with the 123, ending with a similar result to the do example:

  let n = 1
  if n > 0
     then
      123
      else
      0
@DestyNova
Copy link
Author

Update: I was able to make manual alignment easier with let g:haskell_indent_if = 2, although it still autoindents else too far after one or more newlines.

@DestyNova
Copy link
Author

I've added a testcase for this situation in PR #128, but I don't know enough vimscript to fix it ATM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant