Fixed line endings not having the right line endings in CRLF files with autoCRLF=false
This also fixes the stage line/hunk issues of #221 and #213
This commit is contained in:
parent
8d863492ed
commit
765bae578f
@ -4,7 +4,5 @@ import org.eclipse.jgit.diff.RawText
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun RawText.lineAt(line: Int): String {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
this.writeLine(outputStream, line)
|
||||
return outputStream.toString(Charsets.UTF_8)
|
||||
return this.getString(line, line + 1, false)
|
||||
}
|
@ -67,41 +67,20 @@ class FormatHunksUseCase @Inject constructor() {
|
||||
|
||||
while (oldCurrentLine < oldEndLine || newCurrentLine < newEndLine) {
|
||||
if (oldCurrentLine < curEdit.beginA || endIdx + 1 < curIdx) {
|
||||
var lineText = oldRawText.lineAt(oldCurrentLine)
|
||||
|
||||
if (
|
||||
oldCurrentLine < oldRawText.size() - 1 || // If it's not the last
|
||||
(oldCurrentLine == oldRawText.size() - 1 && !oldRawText.isMissingNewlineAtEnd) // Or is the last and contains new line at the end
|
||||
) {
|
||||
lineText += oldRawText.lineDelimiter.orEmpty()
|
||||
}
|
||||
val lineText = oldRawText.lineAt(oldCurrentLine)
|
||||
|
||||
lines.add(Line(lineText, oldCurrentLine, newCurrentLine, LineType.CONTEXT))
|
||||
|
||||
oldCurrentLine++
|
||||
newCurrentLine++
|
||||
} else if (oldCurrentLine < curEdit.endA) {
|
||||
var lineText = oldRawText.lineAt(oldCurrentLine)
|
||||
|
||||
if (
|
||||
oldCurrentLine < oldRawText.size() - 1 || // If it's not the last
|
||||
(oldCurrentLine == oldRawText.size() - 1 && !oldRawText.isMissingNewlineAtEnd) // Or is the last and contains new line at the end
|
||||
) {
|
||||
lineText += oldRawText.lineDelimiter.orEmpty()
|
||||
}
|
||||
val lineText = oldRawText.lineAt(oldCurrentLine)
|
||||
|
||||
lines.add(Line(lineText, oldCurrentLine, newCurrentLine, LineType.REMOVED))
|
||||
|
||||
oldCurrentLine++
|
||||
} else if (newCurrentLine < curEdit.endB) {
|
||||
var lineText = newRawText.lineAt(newCurrentLine)
|
||||
|
||||
if (
|
||||
newCurrentLine < newRawText.size() - 1 || // If it's not the last
|
||||
(newCurrentLine == newRawText.size() - 1 && !newRawText.isMissingNewlineAtEnd) // Or is the last and contains new line at the end
|
||||
) {
|
||||
lineText += newRawText.lineDelimiter.orEmpty()
|
||||
}
|
||||
val lineText = newRawText.lineAt(newCurrentLine)
|
||||
|
||||
lines.add(Line(lineText, oldCurrentLine, newCurrentLine, LineType.ADDED))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user