提交 2eec8437 编写于 作者: A Alex Dima

Add IModelContentChangedEvent2.isFlush

上级 307fda26
......@@ -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 {
......
......@@ -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;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册