Help us shape the future of Go! Take the 2026 Go Developer Survey

diff

package
v1.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package diff renders the TUI's diff page: two versions of one entry compared with github.com/aymanbagabas/go-udiff (the same engine the CLI uses), colorized per line in a scrollable viewport. The default layout is a unified diff; `s` toggles a SIDE-BY-SIDE (two-column, old | new) layout that degrades back to unified on a terminal too narrow to split (#674). Both layouts share the same udiff engine — side-by-side is a rendering option, not a second diff. A value that parses as JSON is ALWAYS pretty-printed before diffing (parity with the GUI, which formats every JSON value; #732) — no manual toggle — in both columns. When pretty-printing collapses the two sides to identical text even though the raw values differ (a whitespace-only difference), the page says so rather than showing a bare "(no differences)".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the diff page: it fetches two versions' values once, then renders (and re-renders, for parse-json) their unified diff.

func New

func New(ctx context.Context, req nav.OpenDiff, st styles.Styles, km keys.Map) *Model

New builds a diff page from a navigation request. ctx is the Run context threaded through the fetch. It does not fetch yet; Init dispatches the load.

func NewStatic

func NewStatic(content data.DiffContent, st styles.Styles, km keys.Map) *Model

NewStatic builds a diff page over already-known content (no fetch). It backs the staging page's remote-vs-staged detail, where the two sides are the staged review's values rather than two provider versions. Secret masking is honored exactly as in the fetched path.

func (*Model) HelpKeyMap

func (m *Model) HelpKeyMap() help.KeyMap

HelpKeyMap reports the diff page's context-aware bindings for the help bar: scroll always, the layout toggle (`s`, side-by-side ⇄ unified) on a loaded diff, the mask toggle only on a loaded secret diff (`x` is a no-op on a non-secret diff, so it is hidden there), then back. The help bar makes `s`/`x`/esc discoverable — previously undocumented (#681, #674).

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init dispatches the one-shot version-contents fetch, or nothing for a static page whose content is already known.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (*Model, tea.Cmd)

Update handles fetch results, keys, and mouse wheel scrolling. It returns itself as a page (the app stores it back).

func (*Model) View

func (m *Model) View(width, height int) string

View renders the diff page into the given content area.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL