Documentation
¶
Index ¶
- Constants
- func CompareDirectories(leftDir, rightDir string) (string, error)
- func ComputeHunkWordDiffs(hunk *Hunk) map[int]WordDiffResult
- func CountTrailingWhitespace(content string) int
- func GeneratePatch(files []FileChange, selection SelectionState) string
- func GeneratePatchForTag(files []FileChange, selection SelectionState) string
- func GetLeadingWhitespace(content string) string
- func GetSelectedHunksMap(files []FileChange, selectionState interface{ ... }) map[string]map[int]bool
- func GetUnselectedFiles(files []FileChange, selection SelectionState) []string
- func HasTrailingWhitespace(content string) bool
- func IsWhitespaceOnlyChange(oldContent, newContent string) bool
- func RenderWhitespaceSimple(content string, tabWidth int) string
- func SelectAll(files []FileChange, selection interface{ ... })
- type Applier
- type ChangeType
- type DiffSource
- type DirectorySource
- type FileChange
- type Hunk
- type IntraLineSpan
- type Line
- type LinePair
- type LineType
- type RevisionSource
- type SelectionState
- type SpanType
- type WhitespaceRenderer
- type WordDiffResult
Constants ¶
const ( TabChar = '→' SpaceChar = '·' TrailingSpaceStr = "␣" )
Variables ¶
This section is empty.
Functions ¶
func CompareDirectories ¶
CompareDirectories generates a unified diff comparing two directories. Returns git-format diff text suitable for parsing by diff.Parse().
func ComputeHunkWordDiffs ¶
func ComputeHunkWordDiffs(hunk *Hunk) map[int]WordDiffResult
func CountTrailingWhitespace ¶
func GeneratePatch ¶
func GeneratePatch(files []FileChange, selection SelectionState) string
func GeneratePatchForTag ¶
func GeneratePatchForTag(files []FileChange, selection SelectionState) string
func GetLeadingWhitespace ¶
GetLeadingWhitespace extracts the leading whitespace from a string
func GetSelectedHunksMap ¶
func GetSelectedHunksMap(files []FileChange, selectionState interface { IsHunkSelected(filePath string, hunkIdx int) bool }) map[string]map[int]bool
GetSelectedHunksMap is deprecated but kept for backward compatibility
func GetUnselectedFiles ¶
func GetUnselectedFiles(files []FileChange, selection SelectionState) []string
GetUnselectedFiles returns paths of files with no selections. These files should be restored to their left state.
func HasTrailingWhitespace ¶
func IsWhitespaceOnlyChange ¶
IsWhitespaceOnlyChange returns true if the two strings differ only in whitespace
func RenderWhitespaceSimple ¶
func SelectAll ¶
func SelectAll(files []FileChange, selection interface { ToggleHunk(filePath string, hunkIdx int) })
SelectAll selects all hunks in all files. Used when user wants to keep all changes (default behavior).
Types ¶
type Applier ¶
Applier handles writing user selections back to the right directory. For diff-editor mode, jj expects the right directory to contain only the changes the user wants to keep.
func NewApplier ¶
func (*Applier) ApplySelections ¶
func (a *Applier) ApplySelections(files []FileChange, selection SelectionState) error
ApplySelections reconstructs files in rightDir based on user selections. - Selected hunks: keep the change (content from right) - Unselected hunks: revert the change (content from left)
type ChangeType ¶
type ChangeType int
const ( ChangeTypeModified ChangeType = iota ChangeTypeAdded ChangeTypeDeleted ChangeTypeRenamed )
func (ChangeType) String ¶
func (ct ChangeType) String() string
type DiffSource ¶
type DiffSource interface {
GetDiff() (string, error)
GetSourceLabel() string
SupportsRevisions() bool
}
DiffSource abstracts the source of diff data. This enables the same UI to work with both jj revisions and directory comparisons.
type DirectorySource ¶
DirectorySource generates diffs by comparing two directories. Used for diff-editor mode where jj passes $left and $right directories.
func NewDirectorySource ¶
func NewDirectorySource(leftPath, rightPath string) *DirectorySource
func (*DirectorySource) GetDiff ¶
func (s *DirectorySource) GetDiff() (string, error)
func (*DirectorySource) GetSourceLabel ¶
func (s *DirectorySource) GetSourceLabel() string
func (*DirectorySource) SupportsRevisions ¶
func (s *DirectorySource) SupportsRevisions() bool
type FileChange ¶
type FileChange struct {
Path string
ChangeType ChangeType
Hunks []Hunk
}
func Parse ¶
func Parse(diffText string) []FileChange
func (*FileChange) AddedLines ¶
func (fc *FileChange) AddedLines() int
func (*FileChange) DeletedLines ¶
func (fc *FileChange) DeletedLines() int
func (*FileChange) TotalLines ¶
func (fc *FileChange) TotalLines() int
type Line ¶
func ProcessHunkHideWhitespace ¶
ProcessHunkHideWhitespace transforms a hunk to hide whitespace-only changes Returns a new set of lines with whitespace changes handled
type LinePair ¶
func FindLinePairs ¶
type RevisionSource ¶
RevisionSource generates diffs from jj revisions.
func NewRevisionSource ¶
func NewRevisionSource(client *jj.Client, revision string) *RevisionSource
func (*RevisionSource) GetDiff ¶
func (s *RevisionSource) GetDiff() (string, error)
func (*RevisionSource) GetSourceLabel ¶
func (s *RevisionSource) GetSourceLabel() string
func (*RevisionSource) SupportsRevisions ¶
func (s *RevisionSource) SupportsRevisions() bool
type SelectionState ¶
type SelectionState interface {
IsHunkSelected(filePath string, hunkIdx int) bool
HasPartialSelection(filePath string, hunkIdx int) bool
IsLineSelected(filePath string, hunkIdx, lineIdx int) bool
}
SelectionState interface for accessing selection state
type WhitespaceRenderer ¶
type WhitespaceRenderer struct {
// contains filtered or unexported fields
}
func NewWhitespaceRenderer ¶
func NewWhitespaceRenderer(tabWidth int, trailingHighlight lipgloss.Style) *WhitespaceRenderer
func (*WhitespaceRenderer) Render ¶
func (r *WhitespaceRenderer) Render(content string) string
type WordDiffResult ¶
type WordDiffResult struct {
OldSpans []IntraLineSpan
NewSpans []IntraLineSpan
}
func ComputeWordDiff ¶
func ComputeWordDiff(oldLine, newLine string) WordDiffResult