shithub: vdiff

Download patch

ref: 78df7cace5c34f04746d3b915d236215a7a2ba66
parent: 4d0dc9dca9e5c1249e262643553aabe059cec220
author: phil9 <telephil9@gmail.com>
date: Tue Nov 23 02:52:41 EST 2021

fix file pattern detection

	when using git/export the diff starts after a '---' line which
	was erroneously detected as a file pattern (ie '--- <filename>').

--- a/vdiff.c
+++ b/vdiff.c
@@ -149,14 +149,14 @@
 	Rectangle cr;
 
 	cr = Rect(0, 0, 1, 1);
-	bg			= allocimage(display, cr, screen->chan, 1, 0xffffffff);
-	fg			= allocimage(display, cr, screen->chan, 1, 0x000000ff);
-	cols[Lfile] = allocimage(display, cr, screen->chan, 1, 0xefefefff);
-	cols[Lsep]  = allocimage(display, cr, screen->chan, 1, 0xeaffffff);
-	cols[Ladd]  = allocimage(display, cr, screen->chan, 1, 0xe6ffedff);
-	cols[Ldel]  = allocimage(display, cr, screen->chan, 1, 0xffeef0ff);
+	bg			= allocimage(display, cr, screen->chan, 1, 0x282828ff);
+	fg			= allocimage(display, cr, screen->chan, 1, 0xebdbb2ff);
+	cols[Lfile] = allocimage(display, cr, screen->chan, 1, 0xa89984ff);
+	cols[Lsep]  = allocimage(display, cr, screen->chan, 1, 0x458588ff);
+	cols[Ladd]  = allocimage(display, cr, screen->chan, 1, 0x98971aff);
+	cols[Ldel]  = allocimage(display, cr, screen->chan, 1, 0xcc241dff);
 	cols[Lnone] = bg;
-	scrollbg    = allocimage(display, cr, screen->chan, 1, 0x999999ff);
+	scrollbg    = allocimage(display, cr, screen->chan, 1, 0x504945ff);
 }
 
 int
@@ -167,9 +167,10 @@
 	type = Lnone;
 	if(strncmp(text, "+++", 3)==0)
 		type = Lfile;
-	else if(strncmp(text, "---", 3)==0)
-		type = Lfile;
-	else if(strncmp(text, "@@", 2)==0)
+	else if(strncmp(text, "---", 3)==0){
+		if(strlen(text) > 4)
+			type = Lfile;
+	}else if(strncmp(text, "@@", 2)==0)
 		type = Lsep;
 	else if(strncmp(text, "+", 1)==0)
 		type = Ladd;