diff --git a/src/vs/editor/common/core/editOperation.ts b/src/vs/editor/common/core/editOperation.ts index 8562b983aad..a22d16e1131 100644 --- a/src/vs/editor/common/core/editOperation.ts +++ b/src/vs/editor/common/core/editOperation.ts @@ -12,7 +12,6 @@ export class EditOperation { public static insert(position: Position, text: string): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(position.lineNumber, position.column, position.lineNumber, position.column), text: text, forceMoveMarkers: true @@ -21,25 +20,20 @@ export class EditOperation { public static delete(range: Range): IIdentifiedSingleEditOperation { return { - identifier: null, range: range, - text: null, - forceMoveMarkers: true + text: null }; } public static replace(range: Range, text: string): IIdentifiedSingleEditOperation { return { - identifier: null, range: range, - text: text, - forceMoveMarkers: false + text: text }; } public static replaceMove(range: Range, text: string): IIdentifiedSingleEditOperation { return { - identifier: null, range: range, text: text, forceMoveMarkers: true diff --git a/src/vs/editor/common/model.ts b/src/vs/editor/common/model.ts index 3208f08a48b..72e7a659884 100644 --- a/src/vs/editor/common/model.ts +++ b/src/vs/editor/common/model.ts @@ -295,8 +295,9 @@ export interface ISingleEditOperation { export interface IIdentifiedSingleEditOperation { /** * An identifier associated with this single edit operation. + * @internal */ - identifier: ISingleEditOperationIdentifier; + identifier?: ISingleEditOperationIdentifier; /** * The range to replace. This can be empty to emulate a simple insert. */ @@ -309,10 +310,11 @@ export interface IIdentifiedSingleEditOperation { * This indicates that this operation has "insert" semantics. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved. */ - forceMoveMarkers: boolean; + forceMoveMarkers?: boolean; /** * This indicates that this operation is inserting automatic whitespace * that can be removed on next model edit operation if `config.trimAutoWhitespace` is true. + * @internal */ isAutoWhitespaceEdit?: boolean; /** diff --git a/src/vs/editor/common/model/textBuffer.ts b/src/vs/editor/common/model/textBuffer.ts index e84789aeb52..7b532f95701 100644 --- a/src/vs/editor/common/model/textBuffer.ts +++ b/src/vs/editor/common/model/textBuffer.ts @@ -290,12 +290,12 @@ export class TextBuffer implements ITextBuffer { } operations[i] = { sortIndex: i, - identifier: op.identifier, + identifier: op.identifier || null, range: validatedRange, rangeOffset: this.getOffsetAt(validatedRange.startLineNumber, validatedRange.startColumn), rangeLength: this.getValueLengthInRange(validatedRange, EndOfLinePreference.TextDefined), lines: op.text ? op.text.split(/\r\n|\r|\n/) : null, - forceMoveMarkers: op.forceMoveMarkers, + forceMoveMarkers: op.forceMoveMarkers || false, isAutoWhitespaceEdit: op.isAutoWhitespaceEdit || false }; } diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 8b8789d7fb2..5cb22619cfd 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -985,11 +985,8 @@ export class TextModel extends Disposable implements model.ITextModel { if (allowTrimLine) { editOperations.push({ - identifier: null, range: new Range(trimLineNumber, 1, trimLineNumber, maxLineColumn), - text: null, - forceMoveMarkers: false, - isAutoWhitespaceEdit: false + text: null }); } diff --git a/src/vs/editor/test/browser/commands/shiftCommand.test.ts b/src/vs/editor/test/browser/commands/shiftCommand.test.ts index bd4a5508475..46172988d4d 100644 --- a/src/vs/editor/test/browser/commands/shiftCommand.test.ts +++ b/src/vs/editor/test/browser/commands/shiftCommand.test.ts @@ -21,10 +21,8 @@ import { LanguageIdentifier } from 'vs/editor/common/modes'; */ export function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn), - text: text, - forceMoveMarkers: false + text: text }; } diff --git a/src/vs/editor/test/browser/commands/sideEditing.test.ts b/src/vs/editor/test/browser/commands/sideEditing.test.ts index ed4f68e6a90..8de67a24c3c 100644 --- a/src/vs/editor/test/browser/commands/sideEditing.test.ts +++ b/src/vs/editor/test/browser/commands/sideEditing.test.ts @@ -205,7 +205,11 @@ suite('SideEditing', () => { const cursor = new Cursor(config, model, viewModel); cursor.setSelections('tests', [selection]); - model.applyEdits([{ range: editRange, text: editText, forceMoveMarkers: editForceMoveMarkers, identifier: null }]); + model.applyEdits([{ + range: editRange, + text: editText, + forceMoveMarkers: editForceMoveMarkers + }]); const actual = cursor.getSelection(); assert.deepEqual(actual.toString(), expected.toString(), msg); diff --git a/src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts b/src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts index 5b6a630c02a..94da8563620 100644 --- a/src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts +++ b/src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts @@ -18,10 +18,8 @@ import { withEditorModel } from 'vs/editor/test/common/editorTestUtils'; */ function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn), - text: text, - forceMoveMarkers: true + text: text }; } @@ -30,10 +28,8 @@ function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number */ export function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn), - text: text, - forceMoveMarkers: false + text: text }; } diff --git a/src/vs/editor/test/browser/testCommand.ts b/src/vs/editor/test/browser/testCommand.ts index 459e74cc059..99e6f4a22fb 100644 --- a/src/vs/editor/test/browser/testCommand.ts +++ b/src/vs/editor/test/browser/testCommand.ts @@ -45,19 +45,15 @@ export function getEditOperation(model: ITextModel, command: editorCommon.IComma var editOperationBuilder: editorCommon.IEditOperationBuilder = { addEditOperation: (range: Range, text: string) => { operations.push({ - identifier: null, range: range, - text: text, - forceMoveMarkers: false + text: text }); }, addTrackedEditOperation: (range: Range, text: string) => { operations.push({ - identifier: null, range: range, - text: text, - forceMoveMarkers: false + text: text }); }, diff --git a/src/vs/editor/test/common/model/editableTextModel.test.ts b/src/vs/editor/test/common/model/editableTextModel.test.ts index f7bc9a1a415..bfefb8427c3 100644 --- a/src/vs/editor/test/common/model/editableTextModel.test.ts +++ b/src/vs/editor/test/common/model/editableTextModel.test.ts @@ -538,10 +538,8 @@ suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () = function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(startLineNumber, startColumn, endLineNumber, endColumn), - text: text.join('\n'), - forceMoveMarkers: false + text: text.join('\n') }; } @@ -586,10 +584,8 @@ suite('EditorModel - EditableTextModel.applyEdits updates mightContainNonBasicAS function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): IIdentifiedSingleEditOperation { return { - identifier: null, range: new Range(startLineNumber, startColumn, endLineNumber, endColumn), - text: text.join('\n'), - forceMoveMarkers: false + text: text.join('\n') }; } @@ -1500,10 +1496,9 @@ suite('EditorModel - EditableTextModel.applyEdits', () => { assertSyncedModels('Hello', (model, assertMirrorModels) => { model.applyEdits([{ - identifier: null, range: new Range(1, 6, 1, 6), text: ' world!', - forceMoveMarkers: false + // forceMoveMarkers: false }]); assertMirrorModels(); @@ -1517,10 +1512,9 @@ suite('EditorModel - EditableTextModel.applyEdits', () => { isFirstTime = false; model.applyEdits([{ - identifier: null, range: new Range(1, 13, 1, 13), text: ' How are you?', - forceMoveMarkers: false + // forceMoveMarkers: false }]); }); }); @@ -1530,10 +1524,9 @@ suite('EditorModel - EditableTextModel.applyEdits', () => { assertSyncedModels('Hello', (model, assertMirrorModels) => { model.applyEdits([{ - identifier: null, range: new Range(1, 6, 1, 6), text: ' world!', - forceMoveMarkers: false + // forceMoveMarkers: false }]); assertMirrorModels(); @@ -1547,10 +1540,9 @@ suite('EditorModel - EditableTextModel.applyEdits', () => { isFirstTime = false; model.applyEdits([{ - identifier: null, range: new Range(1, 13, 1, 13), text: ' How are you?', - forceMoveMarkers: false + // forceMoveMarkers: false }]); }); }); diff --git a/src/vs/editor/test/common/model/editableTextModelAuto.test.ts b/src/vs/editor/test/common/model/editableTextModelAuto.test.ts index 0513e27f37f..6b517049305 100644 --- a/src/vs/editor/test/common/model/editableTextModelAuto.test.ts +++ b/src/vs/editor/test/common/model/editableTextModelAuto.test.ts @@ -229,10 +229,8 @@ class TestModel { let startPosition = offsetToPosition[edits[i].offset]; let endPosition = offsetToPosition[edits[i].offset + edits[i].length]; this.edits.push({ - identifier: null, range: new Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column), - text: edits[i].text, - forceMoveMarkers: false + text: edits[i].text }); } diff --git a/src/vs/editor/test/common/model/model.line.test.ts b/src/vs/editor/test/common/model/model.line.test.ts index e86a8de9edc..2ef7b856f34 100644 --- a/src/vs/editor/test/common/model/model.line.test.ts +++ b/src/vs/editor/test/common/model/model.line.test.ts @@ -446,19 +446,15 @@ suite('ModelLinesTokens', () => { model._tokens._setTokens(0, 0, model.getLineMaxColumn(1) - 1, TestToken.toTokens([new TestToken(0, 1)])); model.applyEdits([{ - identifier: null, range: new Range(1, 1, 1, 10), - text: '', - forceMoveMarkers: false + text: '' }]); model._tokens._setTokens(0, 0, model.getLineMaxColumn(1) - 1, new Uint32Array(0)); model.applyEdits([{ - identifier: null, range: new Range(1, 1, 1, 1), - text: 'a', - forceMoveMarkers: false + text: 'a' }]); const actualTokens = model.getLineTokens(1); diff --git a/src/vs/editor/test/common/model/modelDecorations.test.ts b/src/vs/editor/test/common/model/modelDecorations.test.ts index 4524584fe45..b8c752e6567 100644 --- a/src/vs/editor/test/common/model/modelDecorations.test.ts +++ b/src/vs/editor/test/common/model/modelDecorations.test.ts @@ -424,7 +424,11 @@ suite('Decorations and editing', () => { ].join('\n')); const id = model.deltaDecorations([], [{ range: decRange, options: { stickiness: stickiness } }])[0]; - model.applyEdits([{ range: editRange, text: editText, forceMoveMarkers: editForceMoveMarkers, identifier: null }]); + model.applyEdits([{ + range: editRange, + text: editText, + forceMoveMarkers: editForceMoveMarkers + }]); const actual = model.getDecorationRange(id); assert.deepEqual(actual, expectedDecRange, msg); diff --git a/src/vs/editor/test/common/model/modelEditOperation.test.ts b/src/vs/editor/test/common/model/modelEditOperation.test.ts index 45931c16ff1..ac20a1b71d5 100644 --- a/src/vs/editor/test/common/model/modelEditOperation.test.ts +++ b/src/vs/editor/test/common/model/modelEditOperation.test.ts @@ -42,10 +42,7 @@ suite('Editor Model - Model Edit Operation', () => { ); return { - identifier: { - major: 0, - minor: 0 - }, + identifier: null, range: range, text: text, forceMoveMarkers: false diff --git a/src/vs/editor/test/common/viewModel/viewModelImpl.test.ts b/src/vs/editor/test/common/viewModel/viewModelImpl.test.ts index 637efcb87ab..917c60be194 100644 --- a/src/vs/editor/test/common/viewModel/viewModelImpl.test.ts +++ b/src/vs/editor/test/common/viewModel/viewModelImpl.test.ts @@ -21,7 +21,6 @@ suite('ViewModel', () => { viewModel.setViewport(1, 1, 1); model.applyEdits([{ - identifier: null, range: new Range(1, 1, 1, 1), text: [ 'line01', @@ -34,8 +33,7 @@ suite('ViewModel', () => { 'line08', 'line09', 'line10', - ].join('\n'), - forceMoveMarkers: false + ].join('\n') }]); assert.equal(viewModel.getLineCount(), 10); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 7209b170169..1a97d2c9a01 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1341,10 +1341,6 @@ declare module monaco.editor { * A single edit operation, that has an identifier. */ export interface IIdentifiedSingleEditOperation { - /** - * An identifier associated with this single edit operation. - */ - identifier: ISingleEditOperationIdentifier; /** * The range to replace. This can be empty to emulate a simple insert. */ @@ -1357,12 +1353,7 @@ declare module monaco.editor { * This indicates that this operation has "insert" semantics. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved. */ - forceMoveMarkers: boolean; - /** - * This indicates that this operation is inserting automatic whitespace - * that can be removed on next model edit operation if `config.trimAutoWhitespace` is true. - */ - isAutoWhitespaceEdit?: boolean; + forceMoveMarkers?: boolean; } /** diff --git a/src/vs/workbench/api/electron-browser/mainThreadEditor.ts b/src/vs/workbench/api/electron-browser/mainThreadEditor.ts index 0f5680b8feb..01917e0bd8b 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadEditor.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadEditor.ts @@ -355,7 +355,6 @@ export class MainThreadTextEditor { let transformedEdits = edits.map((edit): IIdentifiedSingleEditOperation => { return { - identifier: null, range: Range.lift(edit.range), text: edit.text, forceMoveMarkers: edit.forceMoveMarkers diff --git a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts index abf71055d30..6e85d133edf 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts @@ -242,7 +242,6 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant { return { text, range: Range.lift(range), - identifier: undefined, forceMoveMarkers: true }; } diff --git a/src/vs/workbench/parts/preferences/common/preferencesModels.ts b/src/vs/workbench/parts/preferences/common/preferencesModels.ts index 05cb08cc55c..0ddf3a581cb 100644 --- a/src/vs/workbench/parts/preferences/common/preferencesModels.ts +++ b/src/vs/workbench/parts/preferences/common/preferencesModels.ts @@ -624,9 +624,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements this._model.applyEdits([ { text: mostRelevantContent, - forceMoveMarkers: false, - range: new Range(mostRelevantLineOffset, 1, mostRelevantEndLine, 1), - identifier: { major: 1, minor: 0 } + range: new Range(mostRelevantLineOffset, 1, mostRelevantEndLine, 1) } ]);