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

splitassign

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package splitassign renders the modal that pairs each split tag with a destination, either an existing revision or a commit to create. The parent model fills it with tags and revisions, routes keys to it while it is visible, and reads the finished pairing back with GetDestinations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DestinationSpec

type DestinationSpec struct {
	ChangeID    string
	Description string
	Type        DestinationType
}

DestinationSpec is where one tag's hunks land. ChangeID is empty for DestNewCommit, where Description becomes the message of the commit that gets created.

type DestinationType

type DestinationType int

DestinationType separates an assignment that targets a revision that already exists from one that creates a commit.

const (
	DestExistingRevision DestinationType = iota
	DestNewCommit
)

Destinations a tag can be sent to. DestExistingRevision is the zero value, so a DestinationSpec that was never filled in reads as targeting an existing revision.

type Model

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

Model is the two-panel assignment modal, tags on the left and candidate revisions on the right, with one cursor per panel. It owns the destination map for the whole split, so the parent model keeps a single instance alive across openings.

func New

func New() Model

New returns a hidden modal with no tags, no revisions, and the tag panel focused.

func (*Model) AssignNewCommitToCurrentTag

func (m *Model) AssignNewCommitToCurrentTag(description string)

AssignNewCommitToCurrentTag sends the selected tag to a commit to be created with description. It does nothing when the tag cursor sits outside the list.

func (*Model) AssignNewCommitToTag

func (m *Model) AssignNewCommitToTag(tag SplitTag, description string)

AssignNewCommitToTag sends a named tag to a commit to be created with description, without regard to the cursor, and records the tag even when it is not in the modal's tag list.

func (*Model) AssignRevisionToCurrentTag

func (m *Model) AssignRevisionToCurrentTag()

AssignRevisionToCurrentTag points the selected tag at the selected revision, replacing any earlier assignment. It does nothing when either cursor sits outside its list.

func (*Model) GetDestinations

func (m *Model) GetDestinations() map[SplitTag]*DestinationSpec

GetDestinations returns the tag-to-destination map by reference, so later assignments are visible through a map the caller already holds. A tag the user never assigned is absent.

func (*Model) Hide

func (m *Model) Hide()

Hide closes the modal, keeping the assignments made so far.

func (*Model) IsVisible

func (m *Model) IsVisible() bool

IsVisible reports whether the modal is open, which is how the parent decides to route keys here.

func (*Model) MoveDown

func (m *Model) MoveDown()

MoveDown moves the focused panel's cursor down one row, stopping at the last.

func (*Model) MoveUp

func (m *Model) MoveUp()

MoveUp moves the focused panel's cursor up one row, stopping at the first.

func (*Model) SetRevisions

func (m *Model) SetRevisions(revisions []jj.RevisionEntry)

SetRevisions replaces the candidate revisions and rewinds the revision cursor when it would sit past the end. Order is preserved because the caller decides which revisions are worth offering.

func (*Model) SetTags

func (m *Model) SetTags(tags []SplitTag)

SetTags adopts tags as the tag list and sorts it ascending, which reorders the caller's slice in place. The tag cursor rewinds when it would sit past the end. Assignments are untouched, including any belonging to a tag that is no longer listed.

func (*Model) Show

func (m *Model) Show()

Show opens the modal with the tag panel focused, whatever panel was focused when it last closed.

func (*Model) ToggleFocus

func (m *Model) ToggleFocus()

ToggleFocus swaps the cursor between the tag panel and the revision panel.

func (*Model) View

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

View renders the modal centered in the given terminal size, returning the empty string while hidden.

type SplitTag

type SplitTag rune

SplitTag is the single character a hunk carries while a multi-way split is being assembled. It is declared here rather than shared with the parent model so this component imports nothing from it.

Jump to

Keyboard shortcuts

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