microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.42k stars 29.34k forks source link

Staging when ignoring whitespace, doesn't stage changed whitespace #63397

Open garyking opened 5 years ago

garyking commented 5 years ago

Issue Type: Bug

  1. Indent several lines of code, and save. These should appear as changes in Git.
  2. Click on "Open changes".
  3. Ensure whitespace changes are hidden (which is the default).
  4. Select the indented lines, and stage them with "Stage selected ranges".
  5. Nothing is staged. Even though whitespace is hidden, shouldn't changes like indentation be staged, if they're within the selected range? Otherwise I end up with lines like if (true) staged, since it's a text change, but the block contained within its braces as not staged, since it's just an indentation change.

VS Code version: Code 1.29.1 (bc24f98b5f70467bc689abf41cc5550ca637088e, 2018-11-15T19:06:21.742Z) OS version: Darwin x64 18.0.0

vscodebot[bot] commented 5 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

joaomoreno commented 5 years ago

Stage selected ranges only works if the diffs are visible. If you show whitespace changes, does the action work?

garyking commented 5 years ago

Yeah, if I show whitespace changes, then it works. But I'm asking, why does it work that way? Meaning, if I have whitespace changes hidden, and I stage a range, then the textual changes are staged, but the whitespace changes are not staged. So I end up with a commit that has changes committed without any indentation, so I have to then stage and commit the indentation separately.

Having whitespace changes hidden definitely makes it easier to identify changes, but having to remember to turn it on before any staging every time, is a bit tedious.

admirabilis commented 5 years ago

To anyone arriving from Google, the current workaround is "diffEditor.ignoreTrimWhitespace": false.

wesinator commented 5 years ago

Stage selected ranges only works if the diffs are visible. If you show whitespace changes, does the action work?

@joaomoreno whitespace changes should be displayed (i.e. not ignored) by default.

For Python , whitespace changes are a critical syntatic and semantic aspect of the code . ignoring whitespace changes by default will break Python code change commits

alystair commented 4 years ago

Thanks @teresaejunior - what a pain in the ass, will use work around. I noticed using selective diff was breaking and had to revert or append commits often. This is currently pretty bad UX :/