Skip to content

Commit 7f9b856

Browse files
committed
1 parent 97e20be commit 7f9b856

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

extensions/git/src/staging.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export function applyLineChanges(original: TextDocument, modified: TextDocument,
2121
let fromLine = diff.modifiedStartLineNumber - 1;
2222
let fromCharacter = 0;
2323

24+
// if this is an insertion at the very end of the document,
25+
// then we must start the next range after the last character of the
26+
// previous line, in order to take the correct eol
2427
if (isInsertion && diff.originalStartLineNumber === original.lineCount) {
25-
fromLine = original.lineCount - 1;
26-
fromCharacter = original.lineAt(fromLine).range.end.character;
28+
fromLine -= 1;
29+
fromCharacter = modified.lineAt(fromLine).range.end.character;
2730
}
2831

2932
result.push(modified.getText(new Range(fromLine, fromCharacter, diff.modifiedEndLineNumber, 0)));

0 commit comments

Comments
 (0)