-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Avoid removing indentation on a new line as trailing white spaces #7307
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
Conversation
|
pinging @vladima |
|
👍 Can you port to |
Avoid removing indentation on a new line as trailing white spaces
|
Shouldn't it have tests? |
|
@mihailik normally it should. Though in this case turns out it is hard to test the behavior, as VSCode indents first and then send the buffer content to the server for formatting; while VS formats first, and then ask the language service about the indentation; and our fourslash tests mimic's VS' behavior. So there is no way to know if a inserted indentation would be removed, as the test suite doesn't insert indentation. I've tested on VS and VSCode to make sure it solves the issue. |
|
I'm not doubting it works, just for the sake of preventing regressions. Wouldn't fourslash work for this case? I've found this example of testing indentation: |
|
You are right verifying indentation is possible. Though the issue here is to verify the indentation after the "format on enter", which is different from formatting the whole document. For example: function test() { // hit enter here
| // cursor location afterwards
}In this case, if you are in the "format on enter" case, the indentation in the current line shouldn't be removed, as you are typing. However if you are formatting the whole document, it should be removed because these are trailing whiltespaces, and formatting the whole document shouldn't be affected be cursor location. I'm saying that testing the former one is difficulty for now. |
|
This seems really overly-complicated for determining whether a line should have an indent or the spacing be removed... I don't think other editors check with servers and go through multiple checks and edits like this. By the way, the problem is happening in .php files with PHP or HTML code, so I'm not sure how TypeScript is involved. |
Fixes #7022 and #6700.