ryu1kn / vscode-partial-diff

Visual Studio Code Extension. Take a diff of 2 parts of text(s)
https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff
MIT License
184 stars 15 forks source link

Filter / Ignore Regex Matches #49

Closed Chiramisu closed 4 years ago

Chiramisu commented 4 years ago

What would make this extension totally boss and superior to any other diffing / compare tool I've ever used, is if it had the ability to add a Regex filter to ignore certain conditions in the comparison. For example, many times I want to compare log files that have timestamps in them, but I only need to compare the content, and timestamps just clutter up the diff making it substantially more work to visually identify lines with actual different content.

I should be able to set any number of Regex filters and any text that matches the pattern should be completely ignored by the diff. 🚀👍🏼

Why nobody has thought of this, I'll never know. Sky's the limit. Useful not just for timestamps, but hashes, UUIDs, random numbers, anything that varies consistently between files of the same ilk that isn't germane to the diffing at hand. 😉

ryu1kn commented 4 years ago

Hi @Chiramisu , I wonder if this option helps you achieve what you want.

  • partialDiff.preComparisonTextNormalizationRules (default: [])

    Rules to normalize texts for diff view.

    It doesn't mutate texts in the editors. Only texts in diff views get normalised. If a diff is presented with text normalised (or possibly normalised), ~ is used in the diff title instead of )

from README

For example, you can remove timestamp differences from the diff with following setting (and enable it with Toggle Pre-Comparison Text Normalization Rules command).


"partialDiff.preComparisonTextNormalizationRules": [
    {
      "name": "Replace timestamp with dummy value",
      "match": "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z",
      "replaceWith": "0000-00-00T00:00:00.000Z",
      "enableOnStart": false
    }
]
ryu1kn commented 4 years ago

I'm closing this. If the above doesn't solve your problem, let me know 👍