1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

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
}
}
}