Hi.

The current behavior of splitting diffs into whitespace-separated tokens
completely obliterates readability of side-by-side diffs. Can we do
something about that?

I'm attaching a patch to handle this case specifically. This isn't very
nice, but it proves the concept.

To make side-by-side diffs look right, ucf needed to be patched also:

  http://bugs.debian.org/862607

With these two patches, these diffs are rendered properly. Should be do
this better in some way?


>From ea0a9f7ca0b440e76907b296f015d3c91d4d119d Mon Sep 17 00:00:00 2001
From: Dima Kogan <dko...@debian.org>
Date: Sun, 14 May 2017 22:12:20 -0700
Subject: [PATCH] Don't split diff content into space-separated tokens

Prior to this patch, diffs are split by spaces and then reconstituted when
rendering. This is not only needless work, but affects readability, since
multiple consecutive spaces are crushed into one.

For side-by-side diffs this DESTROYS readability entirely.

This patch special-cases DIFFs, which possibly is not sufficient, but it solves
this specific issue
---
 Debconf/ConfModule.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Debconf/ConfModule.pm b/Debconf/ConfModule.pm
index b3989a68..4615c247 100644
--- a/Debconf/ConfModule.pm
+++ b/Debconf/ConfModule.pm
@@ -200,6 +200,24 @@ whitespace.
 
 sub unescape_split {
 	my $text=shift;
+
+
+        sub unescape {
+            my $s = shift;
+            $s =~ s/\\([rnt'"\\])/"qq{\\$1}"/gee;
+            return $s;
+        };
+        if ( $text =~ /^
+              (SUBST) \s+
+              (\S+)   \s+
+              (DIFF)  \s+
+              (.*?) $
+             /sx ) {
+
+            return ($1,$2,$3,unescape($4));
+        }
+
+
 	my @words;
 	my $word='';
 	for my $chunk (split /(\\.|\s+)/, $text) {
-- 
2.11.0

Reply via email to