Doesn't edit the model unless an edit is required, which means the undo
stack is updated properly. Behaviour should be similar to
trimTrailingWhitespace
This commit is contained in:
AiryShift
2017-12-07 13:20:16 +11:00
parent 3656454687
commit eb81a0b2f8

View File

@@ -157,7 +157,11 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipant {
currentLine = model.getLineContent(currentLineNumber);
currentLineIsEmptyOrWhitespace = strings.lastNonWhitespaceIndex(currentLine) === -1;
}
model.pushEditOperations(prevSelection, [EditOperation.delete(new Range(currentLineNumber + 1, 1, lineCount + 1, 1))], edits => prevSelection);
const deletionRange = new Range(currentLineNumber + 1, 1, lineCount + 1, 1);
if (!deletionRange.isEmpty()) {
model.pushEditOperations(prevSelection, [EditOperation.delete(deletionRange)], edits => prevSelection);
}
if (editor) {
editor.setSelections(prevSelection);