Sysmagine / SemanticDiff

Community support for SemanticDiff, the programming language aware diff for Visual Studio Code and GitHub.
https://semanticdiff.com
40 stars 0 forks source link

Whitespace collapsing in TSX #32

Open mmueller2012 opened 11 months ago

mmueller2012 commented 11 months ago

Separately on .tsx files, if you add a parent div which causes indentation changes inside the jsx, the diff will detect the added spaces as changes. It isn't something that major but would be nice to have it filtered out especially on bigger files.

image

Originally posted by @gustavoferrara in https://github.com/Sysmagine/SemanticDiff/issues/31#issuecomment-1664770730

mmueller2012 commented 11 months ago

@gustavoferrara: I split this into a separate issue.

Adding or removing whitespace around HTML tags can make a visual difference, but it is very difficult to determine if this is the case. Not only is the whitespace collapsing algorithm quite complex, but its behavior changes based on various CSS attributes (display, white-space, white-space-collapse, white-space-trim, text direction, etc.). This can only be correctly determined at runtime.

In order not to hide any visual changes, we decided to show all whitespace differences for now. I am not really happy with this solution either. It is also the main reason why we don't have HTML support yet.

Which solution do you prefer?

gustavoferrara commented 11 months ago

Initially i would think ignoring all whitespaces around tags would be best for me. Ideally you could let each user decide what behavior they prefer via a setting in vscode until you guys can come up with a more permanent solution.

mmueller2012 commented 2 weeks ago

@gustavoferrara We have just released SemanticDiff 0.9.0 with improved JSX/TSX whitespace handling. See the release announcement for more information.

Does this solve the issue for you?