Support selecting file range in patch builder

test: add move_range_to_index

test: add toggle_range
This commit is contained in:
Aaron Hoffman 2024-01-24 19:16:30 -06:00 committed by Jesse Duffield
parent 9b2a5f636a
commit 510f9a1ae1
6 changed files with 247 additions and 24 deletions

View file

@ -80,13 +80,15 @@ func (p *PatchBuilder) PatchToApply(reverse bool) string {
}
func (p *PatchBuilder) addFileWhole(info *fileInfo) {
info.mode = WHOLE
lineCount := len(strings.Split(info.diff, "\n"))
// add every line index
// TODO: add tests and then use lo.Range to simplify
info.includedLineIndices = make([]int, lineCount)
for i := 0; i < lineCount; i++ {
info.includedLineIndices[i] = i
if info.mode != WHOLE {
info.mode = WHOLE
lineCount := len(strings.Split(info.diff, "\n"))
// add every line index
// TODO: add tests and then use lo.Range to simplify
info.includedLineIndices = make([]int, lineCount)
for i := 0; i < lineCount; i++ {
info.includedLineIndices[i] = i
}
}
}