Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored and hwhung0111 committed Aug 28, 2019
1 parent 01689e5 commit 08b98f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/vs/editor/common/controller/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,17 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
autoClosedEnclosingRanges.push(new Range(lineNumber, openCharIndex + 1, lineNumber, closeCharIndex + 2));
}
}
return cursorStateComputer(undoEdits);
const selections = cursorStateComputer(undoEdits);
if (selections) {
// Don't recover the selection from markers because
// we know what it should be.
this._isHandling = true;
}

return selections;
});
if (selections) {
this._isHandling = false;
this.setSelections(source, selections);
}
if (autoClosedCharactersRanges.length > 0) {
Expand Down
12 changes: 4 additions & 8 deletions src/vs/workbench/api/browser/mainThreadSaveParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,12 @@ export class FinalNewLineParticipant implements ISaveParticipantParticipant {
return;
}

let prevSelection: Selection[] = [];
const edits = [EditOperation.insert(new Position(lineCount, model.getLineMaxColumn(lineCount)), model.getEOL())];
const editor = findEditor(model, this.codeEditorService);
if (editor) {
prevSelection = editor.getSelections();
}

model.pushEditOperations(prevSelection, [EditOperation.insert(new Position(lineCount, model.getLineMaxColumn(lineCount)), model.getEOL())], edits => prevSelection);

if (editor) {
editor.setSelections(prevSelection);
editor.executeEdits('insertFinalNewLine', edits, editor.getSelections());
} else {
model.pushEditOperations([], edits, () => null);
}
}
}
Expand Down

0 comments on commit 08b98f1

Please sign in to comment.