Fixed unstage hunk not restoring lines properly

This commit is contained in:
Abdelilah El Aissaoui 2022-04-06 19:48:30 +02:00
parent 1e0660dca0
commit ab9c8ce2df

View File

@ -126,7 +126,7 @@ class StatusManager @Inject constructor(
// Restore previously removed lines to the index // Restore previously removed lines to the index
for (line in removedLines) { for (line in removedLines) {
// Check how many lines before this one have been deleted // Check how many lines before this one have been deleted
val previouslyRemovedLines = addedLines.count { it.newLineNumber <= line.newLineNumber } - 1 val previouslyRemovedLines = addedLines.count { it.newLineNumber < line.newLineNumber }
textLines.add(line.newLineNumber + linesAdded - previouslyRemovedLines, line.text.withoutLineEnding) textLines.add(line.newLineNumber + linesAdded - previouslyRemovedLines, line.text.withoutLineEnding)
linesAdded++ linesAdded++
} }