This repository was archived by the owner on Sep 6, 2021. It is now read-only.
[cmv4] Fix case of hitting Tab at the beginning of a whitespace-only line #7167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update to fix for #7022 to deal with a regression that the previous fix introduced. If you hit tab at the beginning of a whitespace-only line, we used to autoindent to the right level. Now we just insert another indent. This brings back the original behavior (and adds unit tests for it).
Note that the ideal fix here would be to do autoindent when you're anywhere in a whitespace-only line if the amount of whitespace is less than or equal to the correct indent level. However, this isn't easy for us to fix because we can't easily tell in advance what the right indent level is, so we don't know if you're before it or past it (and if you're past it, we don't want to autoindent on Tab, since that would actually outdent; we want to just add another indent in that case). So, the prior behavior (which this reinstates) is to only do the autoindent if the cursor is at the left edge of the line to begin with.
That same issue prevents us from autoindenting when you're immediately before the first non-whitespace character in the line. I'll file a bug to address these cases in the future.