adobe/brackets — pull request #7167 by njx (2014-03-11 22:12:43+00:00)
Title: Fix case of hitting Tab at the beginning of a whitespace-only line

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.