kpdecker / jsdiff

A javascript text differencing implementation.
BSD 3-Clause "New" or "Revised" License
7.75k stars 491 forks source link

Modify node_example.js to support showing added/deleted spaces #479

Closed ExplodingCabbage closed 6 months ago

ExplodingCabbage commented 6 months ago

Resolves https://github.com/kpdecker/jsdiff/issues/414

As noted there, we can't color both the background and text in green/red of different shades, like the HTML example does, because terminals only support a limited number of shades and "red" text on "bright red" background is almost completely illegible on some terminals. Therefore this PR swaps us from coloring ONLY the text to instead coloring ONLY the background. This should still clearly show what letters are added/deleted, but now also makes added/deleted spaces visible, which they weren't before.

Here's a screenshot showing the behaviour change:

image