fix(diffview): improve code width and make it half space on each side

Andrey Nering created

Change summary

internal/exp/diffview/diffview.go                                                       | 77 
internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/DarkMode.golden    | 32 
internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/LightMode.golden   | 32 
internal/exp/diffview/testdata/TestDiffView/Split/Default/DarkMode.golden               | 14 
internal/exp/diffview/testdata/TestDiffView/Split/Default/LightMode.golden              | 14 
internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/DarkMode.golden         | 30 
internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/LightMode.golden        | 30 
internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/DarkMode.golden         | 14 
internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/LightMode.golden        | 14 
internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/DarkMode.golden  | 34 
internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/LightMode.golden | 34 
internal/exp/diffview/testdata/TestDiffView/Unified/Default/DarkMode.golden             | 16 
internal/exp/diffview/testdata/TestDiffView/Unified/Default/LightMode.golden            | 16 
internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/DarkMode.golden       | 32 
internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/LightMode.golden      | 32 
internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden              | 14 
internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden             | 14 
internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/DarkMode.golden       | 16 
internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/LightMode.golden      | 16 
19 files changed, 241 insertions(+), 240 deletions(-)

Detailed changes

internal/exp/diffview/diffview.go šŸ”—

@@ -43,9 +43,10 @@ type DiffView struct {
 	unified    udiff.UnifiedDiff
 	edits      []udiff.Edit
 
-	splitHunks      []splitHunk
-	beforeCodeWidth int
-	afterCodeWidth  int
+	splitHunks []splitHunk
+
+	codeWidth     int
+	fullCodeWidth int // with leading symbols
 }
 
 // New creates a new DiffView with default settings.
@@ -128,6 +129,8 @@ func (dv *DiffView) String() string {
 	if err := dv.computeDiff(); err != nil {
 		return err.Error()
 	}
+	dv.convertDiffToSplit()
+	dv.detectCodeWidth()
 
 	switch dv.layout {
 	case layoutUnified:
@@ -141,9 +144,6 @@ func (dv *DiffView) String() string {
 
 // renderUnified renders the unified diff view as a string.
 func (dv *DiffView) renderUnified() string {
-	dv.detectUnifiedWidth()
-
-	codeWidth := dv.width - leadingSymbolsSize
 	beforeNumDigits, afterNumDigits := dv.lineNumberDigits()
 
 	var b strings.Builder
@@ -153,7 +153,7 @@ func (dv *DiffView) renderUnified() string {
 			b.WriteString(dv.style.DividerLine.LineNumber.Render(pad("…", beforeNumDigits)))
 			b.WriteString(dv.style.DividerLine.LineNumber.Render(pad("…", afterNumDigits)))
 		}
-		b.WriteString(dv.style.DividerLine.Code.Width(codeWidth + leadingSymbolsSize).Render(dv.hunkLineFor(h)))
+		b.WriteString(dv.style.DividerLine.Code.Width(dv.fullCodeWidth).Render(dv.hunkLineFor(h)))
 		b.WriteRune('\n')
 
 		beforeLine := h.FromLine
@@ -168,7 +168,7 @@ func (dv *DiffView) renderUnified() string {
 					b.WriteString(dv.style.EqualLine.LineNumber.Render(pad(beforeLine, beforeNumDigits)))
 					b.WriteString(dv.style.EqualLine.LineNumber.Render(pad(afterLine, afterNumDigits)))
 				}
-				b.WriteString(dv.style.EqualLine.Code.Width(codeWidth + leadingSymbolsSize).Render("  " + content))
+				b.WriteString(dv.style.EqualLine.Code.Width(dv.fullCodeWidth).Render("  " + content))
 				beforeLine++
 				afterLine++
 			case udiff.Insert:
@@ -177,7 +177,7 @@ func (dv *DiffView) renderUnified() string {
 					b.WriteString(dv.style.InsertLine.LineNumber.Render(pad(afterLine, afterNumDigits)))
 				}
 				b.WriteString(dv.style.InsertLine.Symbol.Render("+ "))
-				b.WriteString(dv.style.InsertLine.Code.Width(codeWidth).Render(content))
+				b.WriteString(dv.style.InsertLine.Code.Width(dv.codeWidth).Render(content))
 				afterLine++
 			case udiff.Delete:
 				if dv.lineNumbers {
@@ -185,7 +185,7 @@ func (dv *DiffView) renderUnified() string {
 					b.WriteString(dv.style.DeleteLine.LineNumber.Render(pad(" ", afterNumDigits)))
 				}
 				b.WriteString(dv.style.DeleteLine.Symbol.Render("- "))
-				b.WriteString(dv.style.DeleteLine.Code.Width(codeWidth).Render(content))
+				b.WriteString(dv.style.DeleteLine.Code.Width(dv.codeWidth).Render(content))
 				beforeLine++
 			}
 			b.WriteRune('\n')
@@ -197,9 +197,6 @@ func (dv *DiffView) renderUnified() string {
 
 // renderSplit renders the split (side-by-side) diff view as a string.
 func (dv *DiffView) renderSplit() string {
-	dv.convertDiffToSplit()
-	dv.detectSplitWidth()
-
 	beforeNumDigits, afterNumDigits := dv.lineNumberDigits()
 
 	var b strings.Builder
@@ -208,11 +205,11 @@ func (dv *DiffView) renderSplit() string {
 		if dv.lineNumbers {
 			b.WriteString(dv.style.DividerLine.LineNumber.Render(pad("…", beforeNumDigits)))
 		}
-		b.WriteString(dv.style.DividerLine.Code.Width(dv.beforeCodeWidth + leadingSymbolsSize).Render(dv.hunkLineFor(dv.unified.Hunks[i])))
+		b.WriteString(dv.style.DividerLine.Code.Width(dv.fullCodeWidth).Render(dv.hunkLineFor(dv.unified.Hunks[i])))
 		if dv.lineNumbers {
 			b.WriteString(dv.style.DividerLine.LineNumber.Render(pad("…", afterNumDigits)))
 		}
-		b.WriteString(dv.style.DividerLine.Code.Width(dv.afterCodeWidth + leadingSymbolsSize).Render(" "))
+		b.WriteString(dv.style.DividerLine.Code.Width(dv.fullCodeWidth).Render(" "))
 		b.WriteRune('\n')
 
 		beforeLine := h.fromLine
@@ -233,19 +230,19 @@ func (dv *DiffView) renderSplit() string {
 				if dv.lineNumbers {
 					b.WriteString(dv.style.MissingLine.LineNumber.Render(pad(" ", beforeNumDigits)))
 				}
-				b.WriteString(dv.style.MissingLine.Code.Width(dv.beforeCodeWidth + leadingSymbolsSize).Render("  "))
+				b.WriteString(dv.style.MissingLine.Code.Width(dv.fullCodeWidth).Render("  "))
 			case l.before.Kind == udiff.Equal:
 				if dv.lineNumbers {
 					b.WriteString(dv.style.EqualLine.LineNumber.Render(pad(beforeLine, beforeNumDigits)))
 				}
-				b.WriteString(dv.style.EqualLine.Code.Width(dv.beforeCodeWidth + leadingSymbolsSize).Render("  " + beforeContent))
+				b.WriteString(dv.style.EqualLine.Code.Width(dv.fullCodeWidth).Render("  " + beforeContent))
 				beforeLine++
 			case l.before.Kind == udiff.Delete:
 				if dv.lineNumbers {
 					b.WriteString(dv.style.DeleteLine.LineNumber.Render(pad(beforeLine, beforeNumDigits)))
 				}
 				b.WriteString(dv.style.DeleteLine.Symbol.Render("- "))
-				b.WriteString(dv.style.DeleteLine.Code.Width(dv.beforeCodeWidth).Render(beforeContent))
+				b.WriteString(dv.style.DeleteLine.Code.Width(dv.codeWidth).Render(beforeContent))
 				beforeLine++
 			}
 
@@ -254,19 +251,19 @@ func (dv *DiffView) renderSplit() string {
 				if dv.lineNumbers {
 					b.WriteString(dv.style.MissingLine.LineNumber.Render(pad(" ", afterNumDigits)))
 				}
-				b.WriteString(dv.style.MissingLine.Code.Width(dv.afterCodeWidth + leadingSymbolsSize).Render("  "))
+				b.WriteString(dv.style.MissingLine.Code.Width(dv.fullCodeWidth).Render("  "))
 			case l.after.Kind == udiff.Equal:
 				if dv.lineNumbers {
 					b.WriteString(dv.style.EqualLine.LineNumber.Render(pad(afterLine, afterNumDigits)))
 				}
-				b.WriteString(dv.style.EqualLine.Code.Width(dv.afterCodeWidth + leadingSymbolsSize).Render("  " + afterContent))
+				b.WriteString(dv.style.EqualLine.Code.Width(dv.fullCodeWidth).Render("  " + afterContent))
 				afterLine++
 			case l.after.Kind == udiff.Insert:
 				if dv.lineNumbers {
 					b.WriteString(dv.style.InsertLine.LineNumber.Render(pad(afterLine, afterNumDigits)))
 				}
 				b.WriteString(dv.style.InsertLine.Symbol.Render("+ "))
-				b.WriteString(dv.style.InsertLine.Code.Width(dv.afterCodeWidth).Render(afterContent))
+				b.WriteString(dv.style.InsertLine.Code.Width(dv.codeWidth).Render(afterContent))
 				afterLine++
 			}
 
@@ -335,51 +332,55 @@ func (dv *DiffView) hunkShownLines(h *udiff.Hunk) (before, after int) {
 	return
 }
 
-func (dv *DiffView) detectUnifiedWidth() {
-	if dv.width > 0 {
-		return
+func (dv *DiffView) detectCodeWidth() {
+	switch dv.layout {
+	case layoutUnified:
+		dv.detectUnifiedCodeWidth()
+	case layoutSplit:
+		dv.detectSplitCodeWidth()
 	}
+	dv.fullCodeWidth = dv.codeWidth + leadingSymbolsSize
+}
+
+func (dv *DiffView) detectUnifiedCodeWidth() {
+	dv.codeWidth = 0
 
 	for _, h := range dv.unified.Hunks {
 		shownLines := ansi.StringWidth(dv.hunkLineFor(h))
 
 		for _, l := range h.Lines {
-			lineWidth := ansi.StringWidth(strings.TrimSuffix(l.Content, "\n"))
-			lineWidth += leadingSymbolsSize
-			dv.width = max(dv.width, lineWidth, shownLines)
+			lineWidth := ansi.StringWidth(strings.TrimSuffix(l.Content, "\n")) + 1
+			dv.codeWidth = max(dv.codeWidth, lineWidth, shownLines)
 		}
 	}
 }
 
 func (dv *DiffView) convertDiffToSplit() {
+	if dv.layout != layoutSplit {
+		return
+	}
+
 	dv.splitHunks = make([]splitHunk, len(dv.unified.Hunks))
 	for i, h := range dv.unified.Hunks {
 		dv.splitHunks[i] = hunkToSplit(h)
 	}
 }
 
-func (dv *DiffView) detectSplitWidth() {
-	if dv.width > 0 {
-		return
-	}
+func (dv *DiffView) detectSplitCodeWidth() {
+	dv.codeWidth = 0
 
 	for i, h := range dv.splitHunks {
 		shownLines := ansi.StringWidth(dv.hunkLineFor(dv.unified.Hunks[i]))
 
 		for _, l := range h.lines {
-			var lineWidth int
 			if l.before != nil {
 				codeWidth := ansi.StringWidth(strings.TrimSuffix(l.before.Content, "\n")) + 1
-				dv.beforeCodeWidth = max(dv.beforeCodeWidth, codeWidth, shownLines)
-				lineWidth += codeWidth
+				dv.codeWidth = max(dv.codeWidth, codeWidth, shownLines)
 			}
 			if l.after != nil {
 				codeWidth := ansi.StringWidth(strings.TrimSuffix(l.after.Content, "\n")) + 1
-				dv.afterCodeWidth = max(dv.afterCodeWidth, codeWidth, shownLines)
-				lineWidth += codeWidth
+				dv.codeWidth = max(dv.codeWidth, codeWidth, shownLines)
 			}
-			lineWidth += leadingSymbolsSize * 2
-			dv.width = max(dv.width, lineWidth, shownLines)
 		}
 	}
 }

internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/DarkMode.golden šŸ”—

@@ -1,16 +1,16 @@
-Ā  …Ā   @@ -1,13 +1,15 @@             Ā  …Ā                                                   
-Ā  1Ā   package main                  Ā  1Ā   package main                                    
-Ā  2Ā                                 Ā  2Ā                                                   
-Ā  3Ā   import (                      Ā  3Ā   import (                                        
-Ā  4Ā       "fmt"                     Ā  4Ā       "fmt"                                       
-Ā   Ā                                 Ā  5Ā +     "strings"                                   
-Ā  5Ā   )                             Ā  6Ā   )                                               
-Ā  6Ā                                 Ā  7Ā                                                   
-Ā  7Ā   func main() {                 Ā  8Ā   func main() {                                   
-Ā  8Ā       fmt.Println(getContent()) Ā  9Ā       fmt.Println(getContent())                   
-Ā  9Ā   }                             Ā 10Ā   }                                               
-Ā 10Ā                                 Ā 11Ā                                                   
-Ā 11Ā   func getContent() string {    Ā 12Ā   func getContent() string {                      
-Ā 12Ā -     return "Hello, world!"    Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
-Ā   Ā                                 Ā 14Ā +     return content                              
-Ā 13Ā   }                             Ā 15Ā   }                                               
+Ā  …Ā   @@ -1,13 +1,15 @@                               Ā  …Ā                                                   
+Ā  1Ā   package main                                    Ā  1Ā   package main                                    
+Ā  2Ā                                                   Ā  2Ā                                                   
+Ā  3Ā   import (                                        Ā  3Ā   import (                                        
+Ā  4Ā       "fmt"                                       Ā  4Ā       "fmt"                                       
+Ā   Ā                                                   Ā  5Ā +     "strings"                                   
+Ā  5Ā   )                                               Ā  6Ā   )                                               
+Ā  6Ā                                                   Ā  7Ā                                                   
+Ā  7Ā   func main() {                                   Ā  8Ā   func main() {                                   
+Ā  8Ā       fmt.Println(getContent())                   Ā  9Ā       fmt.Println(getContent())                   
+Ā  9Ā   }                                               Ā 10Ā   }                                               
+Ā 10Ā                                                   Ā 11Ā                                                   
+Ā 11Ā   func getContent() string {                      Ā 12Ā   func getContent() string {                      
+Ā 12Ā -     return "Hello, world!"                      Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā                                                   Ā 14Ā +     return content                              
+Ā 13Ā   }                                               Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/LightMode.golden šŸ”—

@@ -1,16 +1,16 @@
-Ā  …Ā   @@ -1,13 +1,15 @@             Ā  …Ā                                                   
-Ā  1Ā   package main                  Ā  1Ā   package main                                    
-Ā  2Ā                                 Ā  2Ā                                                   
-Ā  3Ā   import (                      Ā  3Ā   import (                                        
-Ā  4Ā       "fmt"                     Ā  4Ā       "fmt"                                       
-Ā   Ā                                 Ā  5Ā +     "strings"                                   
-Ā  5Ā   )                             Ā  6Ā   )                                               
-Ā  6Ā                                 Ā  7Ā                                                   
-Ā  7Ā   func main() {                 Ā  8Ā   func main() {                                   
-Ā  8Ā       fmt.Println(getContent()) Ā  9Ā       fmt.Println(getContent())                   
-Ā  9Ā   }                             Ā 10Ā   }                                               
-Ā 10Ā                                 Ā 11Ā                                                   
-Ā 11Ā   func getContent() string {    Ā 12Ā   func getContent() string {                      
-Ā 12Ā -     return "Hello, world!"    Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
-Ā   Ā                                 Ā 14Ā +     return content                              
-Ā 13Ā   }                             Ā 15Ā   }                                               
+Ā  …Ā   @@ -1,13 +1,15 @@                               Ā  …Ā                                                   
+Ā  1Ā   package main                                    Ā  1Ā   package main                                    
+Ā  2Ā                                                   Ā  2Ā                                                   
+Ā  3Ā   import (                                        Ā  3Ā   import (                                        
+Ā  4Ā       "fmt"                                       Ā  4Ā       "fmt"                                       
+Ā   Ā                                                   Ā  5Ā +     "strings"                                   
+Ā  5Ā   )                                               Ā  6Ā   )                                               
+Ā  6Ā                                                   Ā  7Ā                                                   
+Ā  7Ā   func main() {                                   Ā  8Ā   func main() {                                   
+Ā  8Ā       fmt.Println(getContent())                   Ā  9Ā       fmt.Println(getContent())                   
+Ā  9Ā   }                                               Ā 10Ā   }                                               
+Ā 10Ā                                                   Ā 11Ā                                                   
+Ā 11Ā   func getContent() string {                      Ā 12Ā   func getContent() string {                      
+Ā 12Ā -     return "Hello, world!"                      Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā                                                   Ā 14Ā +     return content                              
+Ā 13Ā   }                                               Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Split/Default/DarkMode.golden šŸ”—

@@ -1,7 +1,7 @@
-Ā  …Ā   @@ -5,5 +5,6 @@                  Ā  …Ā                                  
-Ā  5Ā   )                                Ā  5Ā   )                              
-Ā  6Ā                                    Ā  6Ā                                  
-Ā  7Ā   func main() {                    Ā  7Ā   func main() {                  
-Ā  8Ā -     fmt.Println("Hello, world!") Ā  8Ā +     content := "Hello, world!" 
-Ā   Ā                                    Ā  9Ā +     fmt.Println(content)       
-Ā  9Ā   }                                Ā 10Ā   }                              
+Ā  …Ā   @@ -5,5 +5,6 @@                  Ā  …Ā                                    
+Ā  5Ā   )                                Ā  5Ā   )                                
+Ā  6Ā                                    Ā  6Ā                                    
+Ā  7Ā   func main() {                    Ā  7Ā   func main() {                    
+Ā  8Ā -     fmt.Println("Hello, world!") Ā  8Ā +     content := "Hello, world!"   
+Ā   Ā                                    Ā  9Ā +     fmt.Println(content)         
+Ā  9Ā   }                                Ā 10Ā   }                                

internal/exp/diffview/testdata/TestDiffView/Split/Default/LightMode.golden šŸ”—

@@ -1,7 +1,7 @@
-Ā  …Ā   @@ -5,5 +5,6 @@                  Ā  …Ā                                  
-Ā  5Ā   )                                Ā  5Ā   )                              
-Ā  6Ā                                    Ā  6Ā                                  
-Ā  7Ā   func main() {                    Ā  7Ā   func main() {                  
-Ā  8Ā -     fmt.Println("Hello, world!") Ā  8Ā +     content := "Hello, world!" 
-Ā   Ā                                    Ā  9Ā +     fmt.Println(content)       
-Ā  9Ā   }                                Ā 10Ā   }                              
+Ā  …Ā   @@ -5,5 +5,6 @@                  Ā  …Ā                                    
+Ā  5Ā   )                                Ā  5Ā   )                                
+Ā  6Ā                                    Ā  6Ā                                    
+Ā  7Ā   func main() {                    Ā  7Ā   func main() {                    
+Ā  8Ā -     fmt.Println("Hello, world!") Ā  8Ā +     content := "Hello, world!"   
+Ā   Ā                                    Ā  9Ā +     fmt.Println(content)         
+Ā  9Ā   }                                Ā 10Ā   }                                

internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/DarkMode.golden šŸ”—

@@ -1,15 +1,15 @@
-Ā  …Ā   @@ -2,6 +2,7 @@            Ā  …Ā                                                   
-Ā  2Ā                              Ā  2Ā                                                   
-Ā  3Ā   import (                   Ā  3Ā   import (                                        
-Ā  4Ā       "fmt"                  Ā  4Ā       "fmt"                                       
-Ā   Ā                              Ā  5Ā +     "strings"                                   
-Ā  5Ā   )                          Ā  6Ā   )                                               
-Ā  6Ā                              Ā  7Ā                                                   
-Ā  7Ā   func main() {              Ā  8Ā   func main() {                                   
-Ā  …Ā   @@ -9,5 +10,6 @@           Ā  …Ā                                                   
-Ā  9Ā   }                          Ā 10Ā   }                                               
-Ā 10Ā                              Ā 11Ā                                                   
-Ā 11Ā   func getContent() string { Ā 12Ā   func getContent() string {                      
-Ā 12Ā -     return "Hello, world!" Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
-Ā   Ā                              Ā 14Ā +     return content                              
-Ā 13Ā   }                          Ā 15Ā   }                                               
+Ā  …Ā   @@ -2,6 +2,7 @@                                 Ā  …Ā                                                   
+Ā  2Ā                                                   Ā  2Ā                                                   
+Ā  3Ā   import (                                        Ā  3Ā   import (                                        
+Ā  4Ā       "fmt"                                       Ā  4Ā       "fmt"                                       
+Ā   Ā                                                   Ā  5Ā +     "strings"                                   
+Ā  5Ā   )                                               Ā  6Ā   )                                               
+Ā  6Ā                                                   Ā  7Ā                                                   
+Ā  7Ā   func main() {                                   Ā  8Ā   func main() {                                   
+Ā  …Ā   @@ -9,5 +10,6 @@                                Ā  …Ā                                                   
+Ā  9Ā   }                                               Ā 10Ā   }                                               
+Ā 10Ā                                                   Ā 11Ā                                                   
+Ā 11Ā   func getContent() string {                      Ā 12Ā   func getContent() string {                      
+Ā 12Ā -     return "Hello, world!"                      Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā                                                   Ā 14Ā +     return content                              
+Ā 13Ā   }                                               Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/LightMode.golden šŸ”—

@@ -1,15 +1,15 @@
-Ā  …Ā   @@ -2,6 +2,7 @@            Ā  …Ā                                                   
-Ā  2Ā                              Ā  2Ā                                                   
-Ā  3Ā   import (                   Ā  3Ā   import (                                        
-Ā  4Ā       "fmt"                  Ā  4Ā       "fmt"                                       
-Ā   Ā                              Ā  5Ā +     "strings"                                   
-Ā  5Ā   )                          Ā  6Ā   )                                               
-Ā  6Ā                              Ā  7Ā                                                   
-Ā  7Ā   func main() {              Ā  8Ā   func main() {                                   
-Ā  …Ā   @@ -9,5 +10,6 @@           Ā  …Ā                                                   
-Ā  9Ā   }                          Ā 10Ā   }                                               
-Ā 10Ā                              Ā 11Ā                                                   
-Ā 11Ā   func getContent() string { Ā 12Ā   func getContent() string {                      
-Ā 12Ā -     return "Hello, world!" Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
-Ā   Ā                              Ā 14Ā +     return content                              
-Ā 13Ā   }                          Ā 15Ā   }                                               
+Ā  …Ā   @@ -2,6 +2,7 @@                                 Ā  …Ā                                                   
+Ā  2Ā                                                   Ā  2Ā                                                   
+Ā  3Ā   import (                                        Ā  3Ā   import (                                        
+Ā  4Ā       "fmt"                                       Ā  4Ā       "fmt"                                       
+Ā   Ā                                                   Ā  5Ā +     "strings"                                   
+Ā  5Ā   )                                               Ā  6Ā   )                                               
+Ā  6Ā                                                   Ā  7Ā                                                   
+Ā  7Ā   func main() {                                   Ā  8Ā   func main() {                                   
+Ā  …Ā   @@ -9,5 +10,6 @@                                Ā  …Ā                                                   
+Ā  9Ā   }                                               Ā 10Ā   }                                               
+Ā 10Ā                                                   Ā 11Ā                                                   
+Ā 11Ā   func getContent() string {                      Ā 12Ā   func getContent() string {                      
+Ā 12Ā -     return "Hello, world!"                      Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā                                                   Ā 14Ā +     return content                              
+Ā 13Ā   }                                               Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/DarkMode.golden šŸ”—

@@ -1,7 +1,7 @@
-  @@ -5,5 +5,6 @@                                                   
-  )                                  )                              
-                                                                    
-  func main() {                      func main() {                  
--     fmt.Println("Hello, world!") +     content := "Hello, world!" 
-                                   +     fmt.Println(content)       
-  }                                  }                              
+  @@ -5,5 +5,6 @@                                                     
+  )                                  )                                
+                                                                      
+  func main() {                      func main() {                    
+-     fmt.Println("Hello, world!") +     content := "Hello, world!"   
+                                   +     fmt.Println(content)         
+  }                                  }                                

internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/LightMode.golden šŸ”—

@@ -1,7 +1,7 @@
-  @@ -5,5 +5,6 @@                                                   
-  )                                  )                              
-                                                                    
-  func main() {                      func main() {                  
--     fmt.Println("Hello, world!") +     content := "Hello, world!" 
-                                   +     fmt.Println(content)       
-  }                                  }                              
+  @@ -5,5 +5,6 @@                                                     
+  )                                  )                                
+                                                                      
+  func main() {                      func main() {                    
+-     fmt.Println("Hello, world!") +     content := "Hello, world!"   
+                                   +     fmt.Println(content)         
+  }                                  }                                

internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/DarkMode.golden šŸ”—

@@ -1,17 +1,17 @@
-Ā  …Ā Ā  …Ā   @@ -1,13 +1,15 @@                              
-Ā  1Ā Ā  1Ā   package main                                   
-Ā  2Ā Ā  2Ā                                                  
-Ā  3Ā Ā  3Ā   import (                                       
-Ā  4Ā Ā  4Ā       "fmt"                                      
-Ā   Ā Ā  5Ā +     "strings"                                  
-Ā  5Ā Ā  6Ā   )                                              
-Ā  6Ā Ā  7Ā                                                  
-Ā  7Ā Ā  8Ā   func main() {                                  
-Ā  8Ā Ā  9Ā       fmt.Println(getContent())                  
-Ā  9Ā Ā 10Ā   }                                              
-Ā 10Ā Ā 11Ā                                                  
-Ā 11Ā Ā 12Ā   func getContent() string {                     
-Ā 12Ā Ā   Ā -     return "Hello, world!"                     
-Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!")
-Ā   Ā Ā 14Ā +     return content                             
-Ā 13Ā Ā 15Ā   }                                              
+Ā  …Ā Ā  …Ā   @@ -1,13 +1,15 @@                               
+Ā  1Ā Ā  1Ā   package main                                    
+Ā  2Ā Ā  2Ā                                                   
+Ā  3Ā Ā  3Ā   import (                                        
+Ā  4Ā Ā  4Ā       "fmt"                                       
+Ā   Ā Ā  5Ā +     "strings"                                   
+Ā  5Ā Ā  6Ā   )                                               
+Ā  6Ā Ā  7Ā                                                   
+Ā  7Ā Ā  8Ā   func main() {                                   
+Ā  8Ā Ā  9Ā       fmt.Println(getContent())                   
+Ā  9Ā Ā 10Ā   }                                               
+Ā 10Ā Ā 11Ā                                                   
+Ā 11Ā Ā 12Ā   func getContent() string {                      
+Ā 12Ā Ā   Ā -     return "Hello, world!"                      
+Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā Ā 14Ā +     return content                              
+Ā 13Ā Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/LightMode.golden šŸ”—

@@ -1,17 +1,17 @@
-Ā  …Ā Ā  …Ā   @@ -1,13 +1,15 @@                              
-Ā  1Ā Ā  1Ā   package main                                   
-Ā  2Ā Ā  2Ā                                                  
-Ā  3Ā Ā  3Ā   import (                                       
-Ā  4Ā Ā  4Ā       "fmt"                                      
-Ā   Ā Ā  5Ā +     "strings"                                  
-Ā  5Ā Ā  6Ā   )                                              
-Ā  6Ā Ā  7Ā                                                  
-Ā  7Ā Ā  8Ā   func main() {                                  
-Ā  8Ā Ā  9Ā       fmt.Println(getContent())                  
-Ā  9Ā Ā 10Ā   }                                              
-Ā 10Ā Ā 11Ā                                                  
-Ā 11Ā Ā 12Ā   func getContent() string {                     
-Ā 12Ā Ā   Ā -     return "Hello, world!"                     
-Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!")
-Ā   Ā Ā 14Ā +     return content                             
-Ā 13Ā Ā 15Ā   }                                              
+Ā  …Ā Ā  …Ā   @@ -1,13 +1,15 @@                               
+Ā  1Ā Ā  1Ā   package main                                    
+Ā  2Ā Ā  2Ā                                                   
+Ā  3Ā Ā  3Ā   import (                                        
+Ā  4Ā Ā  4Ā       "fmt"                                       
+Ā   Ā Ā  5Ā +     "strings"                                   
+Ā  5Ā Ā  6Ā   )                                               
+Ā  6Ā Ā  7Ā                                                   
+Ā  7Ā Ā  8Ā   func main() {                                   
+Ā  8Ā Ā  9Ā       fmt.Println(getContent())                   
+Ā  9Ā Ā 10Ā   }                                               
+Ā 10Ā Ā 11Ā                                                   
+Ā 11Ā Ā 12Ā   func getContent() string {                      
+Ā 12Ā Ā   Ā -     return "Hello, world!"                      
+Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā Ā 14Ā +     return content                              
+Ā 13Ā Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Unified/Default/DarkMode.golden šŸ”—

@@ -1,8 +1,8 @@
-Ā  …Ā Ā  …Ā   @@ -5,5 +5,6 @@                 
-Ā  5Ā Ā  5Ā   )                               
-Ā  6Ā Ā  6Ā                                   
-Ā  7Ā Ā  7Ā   func main() {                   
-Ā  8Ā Ā   Ā -     fmt.Println("Hello, world!")
-Ā   Ā Ā  8Ā +     content := "Hello, world!"  
-Ā   Ā Ā  9Ā +     fmt.Println(content)        
-Ā  9Ā Ā 10Ā   }                               
+Ā  …Ā Ā  …Ā   @@ -5,5 +5,6 @@                  
+Ā  5Ā Ā  5Ā   )                                
+Ā  6Ā Ā  6Ā                                    
+Ā  7Ā Ā  7Ā   func main() {                    
+Ā  8Ā Ā   Ā -     fmt.Println("Hello, world!") 
+Ā   Ā Ā  8Ā +     content := "Hello, world!"   
+Ā   Ā Ā  9Ā +     fmt.Println(content)         
+Ā  9Ā Ā 10Ā   }                                

internal/exp/diffview/testdata/TestDiffView/Unified/Default/LightMode.golden šŸ”—

@@ -1,8 +1,8 @@
-Ā  …Ā Ā  …Ā   @@ -5,5 +5,6 @@                 
-Ā  5Ā Ā  5Ā   )                               
-Ā  6Ā Ā  6Ā                                   
-Ā  7Ā Ā  7Ā   func main() {                   
-Ā  8Ā Ā   Ā -     fmt.Println("Hello, world!")
-Ā   Ā Ā  8Ā +     content := "Hello, world!"  
-Ā   Ā Ā  9Ā +     fmt.Println(content)        
-Ā  9Ā Ā 10Ā   }                               
+Ā  …Ā Ā  …Ā   @@ -5,5 +5,6 @@                  
+Ā  5Ā Ā  5Ā   )                                
+Ā  6Ā Ā  6Ā                                    
+Ā  7Ā Ā  7Ā   func main() {                    
+Ā  8Ā Ā   Ā -     fmt.Println("Hello, world!") 
+Ā   Ā Ā  8Ā +     content := "Hello, world!"   
+Ā   Ā Ā  9Ā +     fmt.Println(content)         
+Ā  9Ā Ā 10Ā   }                                

internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/DarkMode.golden šŸ”—

@@ -1,16 +1,16 @@
-Ā  …Ā Ā  …Ā   @@ -2,6 +2,7 @@                                
-Ā  2Ā Ā  2Ā                                                  
-Ā  3Ā Ā  3Ā   import (                                       
-Ā  4Ā Ā  4Ā       "fmt"                                      
-Ā   Ā Ā  5Ā +     "strings"                                  
-Ā  5Ā Ā  6Ā   )                                              
-Ā  6Ā Ā  7Ā                                                  
-Ā  7Ā Ā  8Ā   func main() {                                  
-Ā  …Ā Ā  …Ā   @@ -9,5 +10,6 @@                               
-Ā  9Ā Ā 10Ā   }                                              
-Ā 10Ā Ā 11Ā                                                  
-Ā 11Ā Ā 12Ā   func getContent() string {                     
-Ā 12Ā Ā   Ā -     return "Hello, world!"                     
-Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!")
-Ā   Ā Ā 14Ā +     return content                             
-Ā 13Ā Ā 15Ā   }                                              
+Ā  …Ā Ā  …Ā   @@ -2,6 +2,7 @@                                 
+Ā  2Ā Ā  2Ā                                                   
+Ā  3Ā Ā  3Ā   import (                                        
+Ā  4Ā Ā  4Ā       "fmt"                                       
+Ā   Ā Ā  5Ā +     "strings"                                   
+Ā  5Ā Ā  6Ā   )                                               
+Ā  6Ā Ā  7Ā                                                   
+Ā  7Ā Ā  8Ā   func main() {                                   
+Ā  …Ā Ā  …Ā   @@ -9,5 +10,6 @@                                
+Ā  9Ā Ā 10Ā   }                                               
+Ā 10Ā Ā 11Ā                                                   
+Ā 11Ā Ā 12Ā   func getContent() string {                      
+Ā 12Ā Ā   Ā -     return "Hello, world!"                      
+Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā Ā 14Ā +     return content                              
+Ā 13Ā Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/LightMode.golden šŸ”—

@@ -1,16 +1,16 @@
-Ā  …Ā Ā  …Ā   @@ -2,6 +2,7 @@                                
-Ā  2Ā Ā  2Ā                                                  
-Ā  3Ā Ā  3Ā   import (                                       
-Ā  4Ā Ā  4Ā       "fmt"                                      
-Ā   Ā Ā  5Ā +     "strings"                                  
-Ā  5Ā Ā  6Ā   )                                              
-Ā  6Ā Ā  7Ā                                                  
-Ā  7Ā Ā  8Ā   func main() {                                  
-Ā  …Ā Ā  …Ā   @@ -9,5 +10,6 @@                               
-Ā  9Ā Ā 10Ā   }                                              
-Ā 10Ā Ā 11Ā                                                  
-Ā 11Ā Ā 12Ā   func getContent() string {                     
-Ā 12Ā Ā   Ā -     return "Hello, world!"                     
-Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!")
-Ā   Ā Ā 14Ā +     return content                             
-Ā 13Ā Ā 15Ā   }                                              
+Ā  …Ā Ā  …Ā   @@ -2,6 +2,7 @@                                 
+Ā  2Ā Ā  2Ā                                                   
+Ā  3Ā Ā  3Ā   import (                                        
+Ā  4Ā Ā  4Ā       "fmt"                                       
+Ā   Ā Ā  5Ā +     "strings"                                   
+Ā  5Ā Ā  6Ā   )                                               
+Ā  6Ā Ā  7Ā                                                   
+Ā  7Ā Ā  8Ā   func main() {                                   
+Ā  …Ā Ā  …Ā   @@ -9,5 +10,6 @@                                
+Ā  9Ā Ā 10Ā   }                                               
+Ā 10Ā Ā 11Ā                                                   
+Ā 11Ā Ā 12Ā   func getContent() string {                      
+Ā 12Ā Ā   Ā -     return "Hello, world!"                      
+Ā   Ā Ā 13Ā +     content := strings.ToUpper("Hello, World!") 
+Ā   Ā Ā 14Ā +     return content                              
+Ā 13Ā Ā 15Ā   }                                               

internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden šŸ”—

@@ -1,7 +1,7 @@
-Ā …Ā Ā …Ā   @@ -1,3 +1,3 @@ 
-Ā 1Ā Ā  Ā - a               
-Ā 2Ā Ā  Ā - b               
-Ā 3Ā Ā  Ā - c               
-Ā  Ā Ā 1Ā + d               
-Ā  Ā Ā 2Ā + e               
-Ā  Ā Ā 3Ā + f               
+Ā …Ā Ā …Ā   @@ -1,3 +1,3 @@   
+Ā 1Ā Ā  Ā - a                 
+Ā 2Ā Ā  Ā - b                 
+Ā 3Ā Ā  Ā - c                 
+Ā  Ā Ā 1Ā + d                 
+Ā  Ā Ā 2Ā + e                 
+Ā  Ā Ā 3Ā + f                 

internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden šŸ”—

@@ -1,7 +1,7 @@
-Ā …Ā Ā …Ā   @@ -1,3 +1,3 @@ 
-Ā 1Ā Ā  Ā - a               
-Ā 2Ā Ā  Ā - b               
-Ā 3Ā Ā  Ā - c               
-Ā  Ā Ā 1Ā + d               
-Ā  Ā Ā 2Ā + e               
-Ā  Ā Ā 3Ā + f               
+Ā …Ā Ā …Ā   @@ -1,3 +1,3 @@   
+Ā 1Ā Ā  Ā - a                 
+Ā 2Ā Ā  Ā - b                 
+Ā 3Ā Ā  Ā - c                 
+Ā  Ā Ā 1Ā + d                 
+Ā  Ā Ā 2Ā + e                 
+Ā  Ā Ā 3Ā + f                 

internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/DarkMode.golden šŸ”—

@@ -1,8 +1,8 @@
-  @@ -5,5 +5,6 @@                 
-  )                               
-                                  
-  func main() {                   
--     fmt.Println("Hello, world!")
-+     content := "Hello, world!"  
-+     fmt.Println(content)        
-  }                               
+  @@ -5,5 +5,6 @@                  
+  )                                
+                                   
+  func main() {                    
+-     fmt.Println("Hello, world!") 
++     content := "Hello, world!"   
++     fmt.Println(content)         
+  }                                

internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/LightMode.golden šŸ”—

@@ -1,8 +1,8 @@
-  @@ -5,5 +5,6 @@                 
-  )                               
-                                  
-  func main() {                   
--     fmt.Println("Hello, world!")
-+     content := "Hello, world!"  
-+     fmt.Println(content)        
-  }                               
+  @@ -5,5 +5,6 @@                  
+  )                                
+                                   
+  func main() {                    
+-     fmt.Println("Hello, world!") 
++     content := "Hello, world!"   
++     fmt.Println(content)         
+  }