Prevents cursor from entering injected text for good.
This commit is contained in:
parent
9a3db30a7a
commit
e898b8d0d0
|
@ -335,15 +335,15 @@ export class CursorsController extends Disposable {
|
|||
// The view positions will be updated when handling finishes
|
||||
return;
|
||||
}
|
||||
const selectionsFromMarkers = this._cursors.readSelectionFromMarkers();
|
||||
const newState = CursorState.fromModelSelections(selectionsFromMarkers);
|
||||
|
||||
if (didStateChange(this.getCursorStates(), newState || [])) {
|
||||
// setStates might remove markers, which could trigger a decoration change.
|
||||
// If there are injected text decorations for that line, `onModelContentChanged` is emitted again
|
||||
// and an endless recursion happens.
|
||||
// This is why we only call setStates if we really need to (this fixes recursion).
|
||||
this.setStates(eventsCollector, 'modelChange', CursorChangeReason.RecoverFromMarkers, newState);
|
||||
// setStates might remove markers, which could trigger a decoration change.
|
||||
// If there are injected text decorations for that line, `onModelContentChanged` is emitted again
|
||||
// and an endless recursion happens.
|
||||
// _isHandling prevents that.
|
||||
this._isHandling = true;
|
||||
try {
|
||||
this.setStates(eventsCollector, 'modelChange', CursorChangeReason.NotSet, this.getCursorStates());
|
||||
} finally {
|
||||
this._isHandling = false;
|
||||
}
|
||||
} else {
|
||||
this._knownModelVersionId = e.versionId;
|
||||
|
@ -731,28 +731,6 @@ export class CursorsController extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
function didStateChange(currentStates: CursorState[], newStates: PartialCursorState[]): boolean {
|
||||
if (currentStates.length !== newStates.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < currentStates.length; i++) {
|
||||
const curState = currentStates[i];
|
||||
const newState = newStates[i];
|
||||
if (newState.modelState) {
|
||||
if (!newState.modelState.equals(curState.modelState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (newState.viewState) {
|
||||
if (!newState.viewState.equals(curState.viewState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
interface IExecContext {
|
||||
readonly model: ITextModel;
|
||||
readonly selectionsBefore: Selection[];
|
||||
|
|
Loading…
Reference in a new issue