mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 16:58:55 -05:00
Add IModelContentChangedEvent2.isFlush
This commit is contained in:
@@ -2476,6 +2476,11 @@ export interface IModelContentChangedEvent2 {
|
||||
* Flag that indicates that this event was generated while redoing.
|
||||
*/
|
||||
readonly isRedoing: boolean;
|
||||
/**
|
||||
* Flag that indicates that all decorations were lost with this edit.
|
||||
* The model has been reset to a new value.
|
||||
*/
|
||||
readonly isFlush: boolean;
|
||||
}
|
||||
/**
|
||||
* An event describing a change in the text of a model.
|
||||
|
||||
@@ -659,7 +659,8 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
|
||||
eol: this._EOL,
|
||||
versionId: -1,
|
||||
isUndoing: this._isUndoing,
|
||||
isRedoing: this._isRedoing
|
||||
isRedoing: this._isRedoing,
|
||||
isFlush: false
|
||||
});
|
||||
|
||||
// console.log('AFTER:');
|
||||
|
||||
@@ -298,7 +298,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected _createContentChangedFlushEvent(): editorCommon.IModelContentChangedFlushEvent {
|
||||
private _createContentChangedFlushEvent(): editorCommon.IModelContentChangedFlushEvent {
|
||||
return {
|
||||
changeType: editorCommon.EventType.ModelRawContentChangedFlush,
|
||||
versionId: this._versionId,
|
||||
@@ -308,15 +308,16 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
|
||||
};
|
||||
}
|
||||
|
||||
protected _emitContentChanged2(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeLength: number, text: string, isUndoing: boolean, isRedoing: boolean): void {
|
||||
var e: editorCommon.IModelContentChangedEvent2 = {
|
||||
protected _emitContentChanged2(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeLength: number, text: string, isUndoing: boolean, isRedoing: boolean, isFlush: boolean): void {
|
||||
const e: editorCommon.IModelContentChangedEvent2 = {
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
rangeLength: rangeLength,
|
||||
text: text,
|
||||
eol: this._EOL,
|
||||
versionId: this.getVersionId(),
|
||||
isUndoing: isUndoing,
|
||||
isRedoing: isRedoing
|
||||
isRedoing: isRedoing,
|
||||
isFlush: isFlush
|
||||
};
|
||||
if (!this._isDisposing) {
|
||||
this.emit(editorCommon.EventType.ModelContentChanged2, e);
|
||||
@@ -372,7 +373,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
|
||||
|
||||
this._emitModelContentChangedFlushEvent(this._createContentChangedFlushEvent());
|
||||
|
||||
this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false);
|
||||
this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false, true);
|
||||
}
|
||||
|
||||
public getValue(eol?: editorCommon.EndOfLinePreference, preserveBOM: boolean = false): string {
|
||||
@@ -595,16 +596,16 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
|
||||
|
||||
public setEOL(eol: editorCommon.EndOfLineSequence): void {
|
||||
this._assertNotDisposed();
|
||||
var newEOL = (eol === editorCommon.EndOfLineSequence.CRLF ? '\r\n' : '\n');
|
||||
const newEOL = (eol === editorCommon.EndOfLineSequence.CRLF ? '\r\n' : '\n');
|
||||
if (this._EOL === newEOL) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
var oldFullModelRange = this.getFullModelRange();
|
||||
var oldModelValueLength = this.getValueLengthInRange(oldFullModelRange);
|
||||
var endLineNumber = this.getLineCount();
|
||||
var endColumn = this.getLineMaxColumn(endLineNumber);
|
||||
const oldFullModelRange = this.getFullModelRange();
|
||||
const oldModelValueLength = this.getValueLengthInRange(oldFullModelRange);
|
||||
const endLineNumber = this.getLineCount();
|
||||
const endColumn = this.getLineMaxColumn(endLineNumber);
|
||||
|
||||
this._EOL = newEOL;
|
||||
this._lineStarts = null;
|
||||
@@ -612,7 +613,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
|
||||
|
||||
this._emitModelContentChangedFlushEvent(this._createContentChangedFlushEvent());
|
||||
|
||||
this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false);
|
||||
this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false, false);
|
||||
}
|
||||
|
||||
public getLineMinColumn(lineNumber: number): number {
|
||||
|
||||
5
src/vs/monaco.d.ts
vendored
5
src/vs/monaco.d.ts
vendored
@@ -2460,6 +2460,11 @@ declare module monaco.editor {
|
||||
* Flag that indicates that this event was generated while redoing.
|
||||
*/
|
||||
readonly isRedoing: boolean;
|
||||
/**
|
||||
* Flag that indicates that all decorations were lost with this edit.
|
||||
* The model has been reset to a new value.
|
||||
*/
|
||||
readonly isFlush: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user