提交 61a035c6 编写于 作者: J Johannes Rieken

fix #37005

上级 16e4888a
......@@ -161,7 +161,7 @@ class FormatOnType implements editorCommon.IEditorContribution {
return;
}
EditOperationsCommand.execute(this.editor, edits);
EditOperationsCommand.execute(this.editor, edits, true);
alertFormattingEdits(edits);
}, (err) => {
......@@ -244,7 +244,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution {
if (!state.validate(this.editor) || isFalsyOrEmpty(edits)) {
return;
}
EditOperationsCommand.execute(this.editor, edits);
EditOperationsCommand.execute(this.editor, edits, false);
alertFormattingEdits(edits);
});
}
......@@ -280,7 +280,7 @@ export abstract class AbstractFormatAction extends EditorAction {
return;
}
EditOperationsCommand.execute(editor, edits);
EditOperationsCommand.execute(editor, edits, false);
alertFormattingEdits(edits);
editor.focus();
}, err => {
......
......@@ -11,16 +11,21 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import { Selection } from 'vs/editor/common/core/selection';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ITextModel, EndOfLineSequence, ISingleEditOperation } from 'vs/editor/common/model';
import { EditOperation } from 'vs/editor/common/core/editOperation';
export class EditOperationsCommand implements editorCommon.ICommand {
static execute(editor: ICodeEditor, edits: TextEdit[]) {
static execute(editor: ICodeEditor, edits: TextEdit[], asCommand: boolean) {
const cmd = new EditOperationsCommand(edits, editor.getSelection());
if (typeof cmd._newEol === 'number') {
editor.getModel().setEOL(cmd._newEol);
}
editor.pushUndoStop();
editor.executeCommand('formatEditsCommand', cmd);
if (!asCommand) {
editor.executeEdits('formatEditsCommand', cmd._edits.map(edit => EditOperation.replace(Range.lift(edit.range), edit.text)));
} else {
editor.executeCommand('formatEditsCommand', cmd);
}
editor.pushUndoStop();
}
......
......@@ -220,7 +220,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
}
private _editsWithEditor(editor: ICodeEditor, edits: ISingleEditOperation[]): void {
EditOperationsCommand.execute(editor, edits);
EditOperationsCommand.execute(editor, edits, false);
}
private _editWithModel(model: ITextModel, edits: ISingleEditOperation[]): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册