mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Stage empty last line removal when using stage line cmd
This commit is contained in:
@@ -13,7 +13,17 @@ export function applyLineChanges(original: TextDocument, modified: TextDocument,
|
||||
const isInsertion = diff.originalEndLineNumber === 0;
|
||||
const isDeletion = diff.modifiedEndLineNumber === 0;
|
||||
|
||||
result.push(original.getText(new Range(currentLine, 0, isInsertion ? diff.originalStartLineNumber : diff.originalStartLineNumber - 1, 0)));
|
||||
let toCharacter = 0;
|
||||
let toLine = isInsertion ? diff.originalStartLineNumber : diff.originalStartLineNumber - 1;
|
||||
|
||||
// if this is a deletion at the very end of the document,then we need to account
|
||||
// for a newline at the end of the last line which may have been deleted
|
||||
if (isDeletion && diff.originalStartLineNumber === original.lineCount) {
|
||||
toLine -= 1;
|
||||
toCharacter = original.lineAt(toLine).range.end.character;
|
||||
}
|
||||
|
||||
result.push(original.getText(new Range(currentLine, 0, toLine, toCharacter)));
|
||||
|
||||
if (!isDeletion) {
|
||||
let fromLine = diff.modifiedStartLineNumber - 1;
|
||||
@@ -114,4 +124,4 @@ export function invertLineChange(diff: LineChange): LineChange {
|
||||
originalStartLineNumber: diff.modifiedStartLineNumber,
|
||||
originalEndLineNumber: diff.modifiedEndLineNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user