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

fix #37005

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