mirror of
https://github.com/desktop/desktop
synced 2024-10-30 06:03:10 +00:00
Fix diffLineNumber
for lines after a "no newline" marker
This commit is contained in:
parent
211ef8fc58
commit
2a686716d0
1 changed files with 7 additions and 1 deletions
|
@ -311,7 +311,6 @@ export class DiffParser {
|
|||
let diffLineNumber = linesConsumed
|
||||
while ((c = this.parseLinePrefix(this.peek()))) {
|
||||
const line = this.readLine()
|
||||
diffLineNumber++
|
||||
|
||||
if (!line) {
|
||||
throw new Error('Expected unified diff line but reached end of diff')
|
||||
|
@ -338,6 +337,13 @@ export class DiffParser {
|
|||
continue
|
||||
}
|
||||
|
||||
// We must increase `diffLineNumber` only when we're certain that the line
|
||||
// is not a "no newline" marker. Otherwise, we'll end up with a wrong
|
||||
// `diffLineNumber` for the next line. This could happen if the last line
|
||||
// in the file doesn't have a newline before the change nor after the
|
||||
// change.
|
||||
diffLineNumber++
|
||||
|
||||
let diffLine: DiffLine
|
||||
|
||||
if (c === DiffPrefixAdd) {
|
||||
|
|
Loading…
Reference in a new issue