-
Notifications
You must be signed in to change notification settings - Fork 48
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
Stop indentation after two newlines (or don't indent after module ... where
)
#52
Comments
I am not sure. I am very aware that this happens (it annoys me too) but I am really not sure whether it is possible to change this. |
I'm trying to find time for this, but in the meantime, I was trying out PureScript, and it doesn't have the indentation behaviour on Might be a starting point. |
It looks like PureScript's implementation doesn't try to detect indentation at all due to the lack of
I've personally just removed while from the indentation rules. |
Yes. @simonyangme is right. Purescript has no automatic indentation at all. I mean theoretically we could add a configuration option that turns the auto-indent on or off ... Or add one that only turns it off for |
I suggest taking a look at the built-in SQL indenter. It auto-indents after parens/brackets, otherwise matches indentation on the previous (only!) line, and pasting after an indented line does not indent the pasted text. |
I had been under the impression that block indentation was required after foo = bar
where
bar = () I believe this means that we don't need post- |
I think this might be related since it is happening after two new lines. I noticed that if I'm on a line below the end of a where block or guard and unindent, hitting enter again will cause it auto indent. I feel like this is bad behavior because if the cursor is at the beginning of a blank line and I start a new line below that, it shouldn't automatically indent. For example, after I finish the last line and hit enter, the cursor is auto indented as expected:
I then backspace to unindent:
Then I hit enter to start a new line with the intention of writing a new function. Instead of the cursor remaining at the beginning of the new line, it's now auto indented again:
I feel like it should be at the beginning since that's where the cursor was before you hit enter.
|
I'm quite a newb when it comes to regex, but I think we could use The relevant line would be at https://github.com/JustusAdam/language-haskell/blob/master/src/extension.ts#L12. |
I haven't noticed this issue in the Python extension, so I looked at their code to see what they did differently. Rather than using
|
@hajinko thanks for looking into that. Clever idea to spy on Python in this case. If I understand you correctly, you have already added it to the Haskell extension and it seems to work well? |
@JustusAdam Yeah, I repackaged the extension with only those few lines changed and it seemed to fix the indentation issues. |
Would you like to submit a PR? |
Replaced "indentationRules" with "onEnterRules" to only trigger indention in the very next line.
Yeah, I'll try. I'm not very familiar with github at the moment so if I make a mistake somewhere I apologize in advance. |
Fixes indentation after two lines #52
This issue is still occurring for me. I've verified that I'm on 3.0.3, and that disabling |
Not entirely sure indentation rules are specified in the syntax packages, so just ignore this if that's not the case.
I find that I often wrestle with the automatic indentation, especially after
where
blocks. For example, pasting in Haskell code, will automatically indent everything after themodule ... where
in the top, which is not really intended. Take e.g.which becomes (when pasted),
It would be great if one could either disable the indentation for
module ... where
specifically, or better yet have the behaviour of resetting indentation after two blank lines in a row.Is this even possible in VS Code?
The text was updated successfully, but these errors were encountered: