Expand description
Carry out moves, in order. diffr carries every plugin’s moves out with
this applier, and crate::Draft runs the same code on a copy, so a
plugin predicts exactly the trees and ids its moves leave.
A move names a region by id, on the one side that holds it, or the file
by ROOT. An unknown id is an error.
Cut { region, at }splits a leaf into the lines beforeat, relative to its first line, and the lines fromaton;atmust fall strictly inside it. The leaf on the other side with itsalignment_id, which has the same length, is cut at the same offset. The first piece on each side keeps its leaf’s ids. The second piece takes a freshidon each side and a freshalignment_idshared by the two, and itsfold_state_idis theidof the lhs piece, or of its only piece. Pieces keep the leaf’s tags and visibility and thechangedspans on their lines. A fold, or the file, cannot be cut.JoinFolds { regions }needs two or more region ids. Each side wraps the ones it holds, which must be two or more consecutive siblings under one parent, in a new fold spanning them, with a freshid, no tags, and an open, unlabelled visibility. When both sides wrap, the two new folds share the lhs fold’sfold_state_id, itsid, so a plugin joins a run and the run matched with it on the other side in one move by listing both runs’ ids. A side holding exactly one of the ids is an error, and so is an id no side holds.LinkFoldState { regions }needs two or more region ids. Every region in any of their fold states, on either side, takes the first region’sfold_state_idand whether it starts collapsed.SetCollapsed { region, collapsed }sets whether every region sharing the region’sfold_state_idstarts collapsed, on both sides: they open and close together. OnROOTit sets whether the file starts hidden.SetLabel { region, label }sets the label of that region alone, or of the file onROOT;Noneclears it.SetTags { region, tags }replaces that region’s tags. The file’s tags are its manifest entry’s, fixed before any diff runs, soROOTis an error.
Fresh ids start above the largest id in the file (and above
ROOT) when a plugin’s moves begin, and fresh alignment_ids above the
largest leaf alignment_id; each is handed out in the order the moves
need them, lhs before rhs.
Structs§
- Applier
- Carries out one plugin’s moves, handing out fresh ids as they need them.
- Fresh
- The next unused
idand leafalignment_idin the file: what a plugin’s moves hand out, in order. A plugin that does not usecrate::Draftpredicts the ids its cuts and joins create with it.