diff --git a/internal/exp/diffview/diffview.go b/internal/exp/diffview/diffview.go index 2f83fa01e2a383a2cabfa73bcaf43c3a318bfb17..19fc3b638d18e2442ce578ae2aa38f0be0eec582 100644 --- a/internal/exp/diffview/diffview.go +++ b/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) } } } diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/DarkMode.golden index f304f5e74493245a7f840ce0535e3af661a192aa..ba018ffa9791596a3c488e7c3405411d010e2ee8 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/LightMode.golden index 6891f469fbbd89fa9e4251c894a4047ddf5d1487..a8cf6d43702328efa72fdba33677e4e90e33aa7a 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/CustomContextLines/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/Default/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/Default/DarkMode.golden index 86acb63306bf03d4a49d540e2f9fb40cf63930fb..8d4ebc3c7e9969369c83ae8f555d622429e7855e 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/Default/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/Default/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/Default/LightMode.golden index c198639301f381e8cec717a83208953ceba99b44..e6d7d3a69e481c226b1af6c27d54ece49029628c 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/Default/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/DarkMode.golden index 1c248902db22d0391e84c1a61b4168c3cc0b7576..d708f0d8998ff022460cf87a17c46f6314d98f7a 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/LightMode.golden index 32d746df6a20ca6b1ec14c2e64624b4e41aa845b..722e9e4dc4f1c4884e3b4cf7c6a36a54804efedb 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/MultipleHunks/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/DarkMode.golden index 270a701b16895e3210f1b52a6666ab81a50dd09b..1b4cf06e3389646e255b40dee08d421645fc0319 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/DarkMode.golden +++ b/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)  + }  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/LightMode.golden index f637b85c434a03924001d94c753c684ffeb2926e..e051c052ba83b1c6e55a57aa6c9ab371fc33294e 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Split/NoLineNumbers/LightMode.golden +++ b/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)  + }  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/DarkMode.golden index 476034952acfa039a8fa4d91cb55fb51797d8846..6c989ee2e605e2a4ab403daf161f17b55d0e57df 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/LightMode.golden index 10ca5458cb5fae3c7f2a716fb2d6c10065ed66da..3b2b70055fe7543a682016b7cc2bdaf7a1ed98a4 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/CustomContextLines/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/Default/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/Default/DarkMode.golden index 50445f4e0ba2228fef78161b2d655b5dd4031921..4695927cc8485cb6362fcc8afccd0ada070197fa 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/Default/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/Default/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/Default/LightMode.golden index fffc7209f0939e453d402fd3d512ca00870dee1a..c554fc2027e7341b548859cbbff00dd489f27455 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/Default/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/DarkMode.golden index 8d96732f3f3a43891fc6e86e95a2f002a5639b26..ceb45a3ee43527597b38816a4c0e85e7f662be8c 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/DarkMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/LightMode.golden index 3b17cd9eab064dc286b0e3196b7dbcc160afde59..49f277689dcd1711d0043387c1d48af75c410abf 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/MultipleHunks/LightMode.golden +++ b/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  }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden index 6bea8fb809ed316716bff912221081340d05edad..82686b43274e8f8cd03d5499fdc0f7c78f2e4850 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden +++ b/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  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden index 6820053e41bc12c3e262d7817e5673e4583f7e70..cfc5925412c5899c6a1bef4444816d80ebf27871 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden +++ b/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  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/DarkMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/DarkMode.golden index 1a971eb0896a7232d0ea03718fb677b310b50348..400304aee45ef3bc75abe12cc416195fd18e78c2 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/DarkMode.golden +++ b/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)  + }  diff --git a/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/LightMode.golden b/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/LightMode.golden index 878ec69d9194d52b0c161f417c06926e3752cc18..07aa5236f2274b4bb645076f511a3b5c87b99586 100644 --- a/internal/exp/diffview/testdata/TestDiffView/Unified/NoLineNumbers/LightMode.golden +++ b/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)  + }