microsoft / vscode

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

Provide ability to ignore all whitespace in diff editor (feature request) #43026

Open simonl65 opened 6 years ago

simonl65 commented 6 years ago

Steps to Reproduce:

  1. In settings it's possible to set "diffEditor.ignoreTrimWhitespace": true
  2. There's no option to ignore all whitespace,

Would it be possible to add "diffEditor.ignoreAllSpaces": true? I believe the command-line to achieve this would be something like git diff --ignore-space-at-eol -b -w [commit]...

h/t Daniel Gomez @ coderwall

[edit] Might only need -w ? [/edit]

tommck commented 5 years ago

It's been over a year and I REALLY would love to have this feature. Any chance it will be implemented?

vitalyzhynov commented 5 years ago

image try to install Beyond Compare. It makes possible to configure diffs in any way. Also sourcetree can help you to configure Beyond Comare. image In vs you will see something like image

tobiasdiez commented 4 years ago

It would be also good if differences in line breaks (not just new/deleted empty lines) could be ignored. That is, the following should be taken to be the same:

aaaa
bbb
aaaabbb
shamoh19 commented 4 years ago

Ability to Ignore whitespace in Visual Studio Code git diff view for sure will be good feature

Looking forward for that

ttjackott commented 4 years ago

This would be really helpful!

rendall commented 4 years ago

As with everything, I have Thoughts On This.

I suspect that opinionated formatters such as Prettier solve one problem but at high cost.

The problem that formatters solve: whitespace and indentation is consistent across developers and time, so that changes between commits are obvious. This reduces errors and cognitive load when reviewing code and when troubleshooting.

Two problems that they aggravate: 1) Expressiveness and facility is important when coding and reading code, and I would argue this is top priority. Opinionated formatters impose a cognitive load on everyone, making individual coders work harder to read their own code 2) Moreover, this raises the bar for entry for new people, making coding a less inclusive industry

A better solution, in my opinion: Do away with whitespace as a concern when writing or reviewing code. Do not impose whitespace and indentation formatting constraints for source code if the language itself does not. Each developer can then individually format code according to how each thinks best.

This is why I support this feature request.

As an industry could stand to move away from having opinions about how other developers format their source code, in favor of expressiveness, ease and inclusiveness.

Lexicality commented 4 years ago

Hi @rendall, thanks for your comment. While well written, it doesn't seem to add any new specifications or refinements to the feature request. While we all would like this feature to ship, we should respect the time of the maintainers and, as per the contributing guidelines, avoid making comments that simply express a desire for something to be done. If we are not willing to add the feature ourselves and submit a pull request, we must wait and trust in the prioritisation system this team has developed to help bring us this free product we all enjoy.

rendall commented 4 years ago

Hi Mr. Robinson. Sincerely sorry my opinion rubbed you the wrong way.

While I don't mind, the code of conduct emphasizes friendliness and patience. Is there another way you can give feedback?

Cheers!

Lexicality commented 4 years ago

I do apologise, I have updated my comment to be less caustic. Incidentally, I use non-binary pronouns. Thank you for your understanding.

rendall commented 4 years ago

Gladly. In case we ever interact again, feel free to share your preferred honorific

soundneedle commented 3 years ago

This would be really helpful even three years later!

pranavq212 commented 3 years ago

This would be really helpful even three years later!

@soundneedle, @farmerpaul, @samuelms1, @navneeth-spotnana, @WilliamLHarms This feature already exists in VS code for long now

By default now it is enabled to ignore whitespace. If not you can check click on this button to disable "Show Whitespace": vscodecompare1

You can notice if I enable setting "Show Whitespace", it is showing all whitespace changes too. vscodecompare2

lenerdz commented 3 years ago

@pranavq212 Thanks! I was just searching for an hour about this.

ahernsean commented 3 years ago

@soundneedle, @farmerpaul, @samuelms1, @navneeth-spotnana, @WilliamLHarms This feature already exists in VS code for long now

By default now it is enabled to ignore whitespace. If not you can check click on this button to disable "Show Whitespace":

You can notice if I enable setting "Show Whitespace", it is showing all whitespace changes too.

That's not quite what people are asking for. It doesn't ignore all whitespace. It ignores leading or trailing whitespace only. image

gm-lunatix commented 3 years ago

Just a ping on this, and an example of formatting changes we'd like to be able turn off and not show in the diff editor (like -w for git diff as someone mentioned previously):

image

jmp75 commented 3 years ago

This is an essential feature. I am currently looking for a breaking change in a git repo that also had uniform formatling applied in between the commits of interest, and this is obnoxiously in the way if using gitlens.

I am longing for the venerable TortoiseDiff winding back to earlier this century: image

johnwest80 commented 3 years ago

Any progress on ignoring all spaces? The below code is exactly the same - there should be a way to not show it as a diff. Thx!

image

SebiTimeWaster commented 3 years ago

this is an essential feature, especially when working with libraries from github.

MCEmperor commented 3 years ago

This is an example of how the spaces in between are ignored in TortoiseGit:

image of TortoiseGitMerge

tommck commented 3 years ago

We have this same problem in Azure DevOps diffing during pull requests too.. it's like a fundamental issue with they way Microsoft seems to do diffing with their dev tools :(

hcoona commented 2 years ago

Seem to be already solved. see https://code.visualstudio.com/updates/v1_20#_toggle-for-ignore-trim-whitespace-in-the-diff-editor

brianjmurrell commented 2 years ago

@hcoona Does that ignore all whitespace or just leading and/or trailing whitespace. If the latter, please re-read the original description of this ticket.

blakeVersigaWPE commented 2 years ago

This is Not solved. This update will ignore leading and trailing whitespace. But, It does Not ignore ALL whitespace changes. For example: This is a test line This is a test line In the above example the diff editor will flag the difference on both sides of the 'a' in the top line, even though, the lines are functionally the same.

On Mon, Dec 27, 2021 at 8:57 PM Shuai Zhang @.***> wrote:

Seem to be already solved. see https://code.visualstudio.com/updates/v1_20#_toggle-for-ignore-trim-whitespace-in-the-diff-editor

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/43026#issuecomment-1001842737, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARFVN6DLVY6AEN42HFDL6KLUTERSZANCNFSM4EPLEUUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Blake Versiga

Business Title

Enterprisewide Programmer Analyst, Principal

E: @. @.> M: 214-755-1772

WP Engine, Inc. 504 Lavaca Street, Suite 1000 Austin, Texas 78701

wpengine.com | twitter https://twitter.com/wpengine | careers http://wpengine-careers.com/ | torquemag.io | velocitize.com

netniV commented 2 years ago

With regards to resolution, I would suspect that until there is a comment or referenced commit on this issue tracker, I wouldn't consider this resolved. That's assuming common practice of linking commits to issue trackers.

Something people may not realise, I had noticed that the whitespace icon but as it was greyed out, thought it meant it was completely disabled for that type of diff. Imagine my aghast when simply clicking the icon, enabled MORE whitespace differences than before (all of which occurred simply because I saved a file whilst having auto-formtiting enabled). Clicking the whitespace icon again, hide those with just leading/trailing whitespace issues.

As mentioned by others though, the "internal/unimportant" whitespace (as some people designate it) still shows up because of these auto-formatter changes and I haven't found a way to make Visual Studio play nicely on that whilst waiting on a built-in option to be implemented.

I have wondered if both options should probably be determined by type of file? The way I would see it, have a global option, then override by file extension as there are some files where different spaces mean everything (yaml and python are two I can recall would like have that issue right now).

burger-digital-dev commented 2 years ago

no solution for this one yet?

jwarkentin commented 2 years ago

I think the ideal solution for everyone is to avoid diffing any non-functional whitespace, which would have to be language specific. This could potentially be done by comparing generated ASTs with an appropriately forgiving parser. However, a diff that could show whitespace changes in strings and ignore everything else would get 90% of the way there.

In my own custom implementation of a solution I needed, I ran into the string problem as well as challenges around multiple newline differences and the location of spaces separating tokens. It quickly became clear that a robust solution really needs to be more syntax aware. Not all whitespace can be ignored to correctly ignore whitespace changes.

Lexicality commented 2 years ago

Mate I just want VSCode to use git diff -w, language specific ASTs seems a bit extra to me

brianjmurrell commented 2 years ago

Let not the perfect be the enemy of the good.

blakeVersigaWPE commented 2 years ago

A diff that could show whitespace changes in strings and ignore everything else would get me 100% there. I use this feature every time I save a file. Prob (50 - 70 times a day) This fix could probably save me 30 mins a day, and even more importantly, avoid conflicts in code.

On Fri, Jan 28, 2022 at 9:10 PM Justin Warkentin @.***> wrote:

I think the ideal solution for everyone is to avoid diffing any non-functional whitespace, which would have to be language specific. This could potentially be done by comparing generated ASTs with an appropriately forgiving parser. However, a diff that could show whitespace changes in strings and ignore everything else would get 90% of the way there.

In my own custom implementation of a solution I needed, I ran into the string problem as well as challenges around multiple newline differences and the location of spaces separating tokens. It quickly became clear that a robust solution really needs to be more syntax aware. Not all whitespace can be ignored to correctly ignore whitespace changes.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/43026#issuecomment-1024819217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARFVN6E3YR2X7TIDYODTQHTUYNLBJANCNFSM4EPLEUUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Blake Versiga

Business Title

Enterprisewide Programmer Analyst, Principal

E: @. @.> M: 214-755-1772

WP Engine, Inc. 504 Lavaca Street, Suite 1000 Austin, Texas 78701

wpengine.com | twitter https://twitter.com/wpengine | careers http://wpengine-careers.com/ | torquemag.io | velocitize.com

gijocode commented 2 years ago

Would really love this feature!

BTW, is there anyway I can make VSCode ignore empty line additions/deletions?

I want vscode to ignore the following difference:

Screenshot 2022-02-22 at 5 55 55 PM
qwk000 commented 2 years ago

4 years later... Why is this so hard? It's a basic fundamental feature.

Has anyone found a good extension that can do it? Your favorite?

franva commented 2 years ago

just hit this issue after 4 years later and happy to join the big long team :)

techanvil commented 2 years ago

+1 for this feature, hope it turns up eventually!

kallik commented 2 years ago

+1 for this, it's driving me mad to look through 300 changes in a file only to find out there are 2 non-whitespace changes and the developer did a "pretty format" resulting in azure devops treating this as a huge change.....

GreyElec commented 2 years ago

+1 for this, working on the task to format the code on submitting, space change shouldn't bother the engineer on the code compare.

blakeVersigaWPE commented 2 years ago

Is this something we could swarm on and get done in a pull request?

On Wed, Aug 11, 2021 at 2:02 PM gm-lunatix @.***> wrote:

Just a ping on this, and an example of formatting changes we'd like to be able turn off and not show in the diff editor (like -w for git diff as someone mentioned previously):

[image: image] https://user-images.githubusercontent.com/73477545/129086851-142e9cdf-bac4-4198-8d0b-1352d6b378ad.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/43026#issuecomment-897075412, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARFVN6CREQLXGSDBBQ3OC4TT4LCMXANCNFSM4EPLEUUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

-- Blake Versiga

Business Title

Enterprisewide Programmer Analyst, Principal

E: @. @.> M: 214-755-1772

WP Engine, Inc. 504 Lavaca Street, Suite 1000 Austin, Texas 78701

wpengine.com | twitter https://twitter.com/wpengine | careers http://wpengine-careers.com/ | torquemag.io | velocitize.com

ncturtle commented 2 years ago

+1 for this

arunPrasanthMuthukumar commented 2 years ago

+1

naustra commented 2 years ago

+1

dtarico-suplari commented 2 years ago

GitHub has this feature and it works really well where you can ignore all whitespace differences. I was directed here because ADO does not have this functionality and apparently it needs to be implemented in VSCode to be available on ADO. Considering many microsoft engineers that use ADO, I'd argue it's in Microsoft's self interest to fix this. Even if it saves just one minute of time per day per engineer for 10,000 engineers, that adds up to the equivalent of 20 full time engineers per year looking at lines with only whitespace changes. The time invested in this would very quickly pay for itself and provide a huge return on investment.

prateekamana commented 2 years ago

Bump, please implement this

blakeVersigaWPE commented 2 years ago

+1

On Mon, May 30, 2022 at 9:29 AM Prateek @.***> wrote:

Bump, please implement this

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/43026#issuecomment-1141224185, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARFVN6D3HBG66L3ZTIT6C5DVMTGEDANCNFSM4EPLEUUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Blake Versiga

Business Title

Enterprisewide Programmer Analyst, Principal

E: @. @.> M: 214-755-1772

WP Engine, Inc. 504 Lavaca Street, Suite 1000 Austin, Texas 78701

wpengine.com | twitter https://twitter.com/wpengine | careers http://wpengine-careers.com/ | torquemag.io | velocitize.com

prateekamana commented 2 years ago

I found a workaround meanwhile, you could download gitk on your computer and open it in your working directory where .git is placed, and it has an option to ignore all whitespaces.

golosovsky commented 2 years ago

+1

This feature would really help

giuseppe-falco commented 2 years ago

+1

ameenbadri7 commented 2 years ago

+1 for this

simonoop commented 2 years ago

4 years and 5 months....

Kilozen commented 2 years ago

I've loved the convenience of having instant diffs in VSCode.

Until, someone on the team used an auto-formatter (which should be no problem), but suddenly I can't review the real code changes among the hundreds of places where something like (1,2) got changed to (1, 2) and I have to spend an hour searching for the obvious expected "ignore ALL whitespace" setting... then realize it actually doesn't exist. (yet) Then I have to go on a research quest to find extensions to fix the problem, and create a new policy for everyone that auto-formatter now must be run at checkpoint times to minimize the risk of unreadable diffs.

I'm sure a lot more people are getting burned by this (and making policy changes to work around it) than just the few who bother to comment here. Surely we don't want people to have to leave the smooth flow of using VSCode to view everyday diffs with some other tool?

I think the diff in VSCode has been great except for this one very strange shortcoming.

(Review quality is safety critical in some fields (like control systems) and good diffs are a tremendous help. I previously had an editor that I liked, except the diff was inadequate. The way I learned about VSCode in the first place was I was searching for a more readable diff tool and someone recommended it. That led to me using it as my main editor.)

Thanks for keeping this issue open; please consider it very valuable. (Is there a way to escalate issues to a Microsoft product team, so it doesn't have to wait for an open source volunteer to fix it?)

ttsak commented 2 years ago

since there seems to be no feedback for VS code , can someone suggest other tool for visual diff that does ignore white space ?

Kilozen commented 2 years ago

since there seems to be no feedback for VS code , can someone suggest other tool for visual diff that does ignore white space ?

If you use GitHub (also a Microsoft product, so feature parity would be nice), you can append ?w=1 (or &w=1) to the end of the diff page URL. (Source: https://stackoverflow.com/a/37145215/175290)