Open EmilHvitfeldt opened 2 months ago
This problem only arises with multiple newline-only lines added; the indentation is correct if there is a single newline or newlines at the end of lines with other code.
hmm this looks like intended behaviour. Editors usually remove previous indentation when pressing enter multiple times to prevent littering unnecessary whitespace in the file.
hmm this looks like intended behaviour. Editors usually remove previous indentation when pressing enter multiple times to prevent littering unnecessary whitespace in the file.
This seems a bit overaggressive to me -- wouldn't it be better to remove that whitespace only on save (if configured to do so)? The only real downside of that leftover whitespace is extra noise in a diff.
To be clear we didn't implement this behaviour, it's vscode doing this. I think it's fairly standard, Emacs and nvim do this as well (though other editors like xcode or textmate don't).
Regarding whitespace noise diff, I'm one of those who find these very annoying :-)
In terms of ergonomics, removing the whitespace is the right thing for the very common action of creating spacing between paragraphs of code. On the other side, what techniques or approaches of code writing does this hinder?
On the other side, what techniques or approaches of code writing does this hinder?
I could see some users wanting to create some extra space within a block before they start writing code, e.g. (using the original issue as an example), insert a bunch of newlines first just to "make space" for writing code, and then move the cursor back upwards to get started. This becomes mildly more inconvenient when indenting whitespace is automatically removed?
I see, I guess this would be a common occurrence for users who like having whitespace at the top and bottom of curly braces. It's worth noting that they're just a tab away of getting the correct indentation back though.
That's a good point -- it looks like a single Tab keypress effectively inserts all the necessary whitespace to get the proper indentation, even with heavier nesting.
Positron Version:
Positron Version: 2024.07.0 (Universal) build 67 Code - OSS Version: 1.91.0 Commit: 58e22e191273c6fcb403c458ddb3088b0b80dcd0 Date: 2024-07-18T04:44:17.582Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0
Steps to reproduce the issue:
https://github.com/user-attachments/assets/83e3845a-0deb-41b2-8705-914ef8709e7c
What did you expect to happen?
For the indentation to remain in effect
Were there any error messages in the Output panel or Developer Tools console?
Nope