diff --git a/src/common/diffPositionMapping.ts b/src/common/diffPositionMapping.ts index 16b0fa66db..ddb8657d68 100644 --- a/src/common/diffPositionMapping.ts +++ b/src/common/diffPositionMapping.ts @@ -83,14 +83,14 @@ export function mapNewPositionToOld(patch: string, line: number): number { } else { // Part of the hunk is before line, part is after. for (const diffLine of diffHunk.diffLines) { - if (diffLine.newLineNumber > line) { - return line + delta; - } if (diffLine.type === DiffChangeType.Add) { delta--; } else if (diffLine.type === DiffChangeType.Delete) { delta++; } + if (diffLine.newLineNumber > line) { + return line + delta; + } } return line + delta; }