MCPcopy Index your code
hub / github.com/jesseduffield/lazygit / IsSingleHunkForWholeFile

Method IsSingleHunkForWholeFile

pkg/commands/patch/patch.go:200–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198}
199
200func (self *Patch) IsSingleHunkForWholeFile() bool {
201 if len(self.hunks) != 1 {
202 return false
203 }
204
205 // We consider a patch to be a single hunk for the whole file if it has only additions or
206 // deletions but not both, and no context lines. This not quite correct, because it will also
207 // return true for a block of added or deleted lines if the diff context size is 0, but in this
208 // case you wouldn't be able to stage things anyway, so it doesn't matter.
209 bodyLines := self.hunks[0].bodyLines
210 return nLinesWithKind(bodyLines, []PatchLineKind{DELETION, CONTEXT}) == 0 ||
211 nLinesWithKind(bodyLines, []PatchLineKind{ADDITION, CONTEXT}) == 0
212}

Callers 2

NewStateFunction · 0.80

Calls 1

nLinesWithKindFunction · 0.85

Tested by 1