@@ -48,14 +48,19 @@ export class CursorStateChangedEvent {
4848 * Reason.
4949 */
5050 readonly reason : CursorChangeReason ;
51+ /**
52+ * The number of cursors was limited because it has reached the maximum cursor count.
53+ */
54+ readonly reachedMaxCursorCount : boolean ;
5155
52- constructor ( selections : Selection [ ] , modelVersionId : number , oldSelections : Selection [ ] | null , oldModelVersionId : number , source : string , reason : CursorChangeReason ) {
56+ constructor ( selections : Selection [ ] , modelVersionId : number , oldSelections : Selection [ ] | null , oldModelVersionId : number , source : string , reason : CursorChangeReason , reachedMaxCursorCount : boolean ) {
5357 this . selections = selections ;
5458 this . modelVersionId = modelVersionId ;
5559 this . oldSelections = oldSelections ;
5660 this . oldModelVersionId = oldModelVersionId ;
5761 this . source = source ;
5862 this . reason = reason ;
63+ this . reachedMaxCursorCount = reachedMaxCursorCount ;
5964 }
6065}
6166
@@ -161,9 +166,6 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
161166
162167 public static readonly MAX_CURSOR_COUNT = 10000 ;
163168
164- private readonly _onDidReachMaxCursorCount : Emitter < void > = this . _register ( new Emitter < void > ( ) ) ;
165- public readonly onDidReachMaxCursorCount : Event < void > = this . _onDidReachMaxCursorCount . event ;
166-
167169 private readonly _onDidAttemptReadOnlyEdit : Emitter < void > = this . _register ( new Emitter < void > ( ) ) ;
168170 public readonly onDidAttemptReadOnlyEdit : Event < void > = this . _onDidAttemptReadOnlyEdit . event ;
169171
@@ -282,9 +284,10 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
282284 }
283285
284286 public setStates ( source : string | null | undefined , reason : CursorChangeReason , states : PartialCursorState [ ] | null ) : boolean {
287+ let reachedMaxCursorCount = false ;
285288 if ( states !== null && states . length > Cursor . MAX_CURSOR_COUNT ) {
286289 states = states . slice ( 0 , Cursor . MAX_CURSOR_COUNT ) ;
287- this . _onDidReachMaxCursorCount . fire ( undefined ) ;
290+ reachedMaxCursorCount = true ;
288291 }
289292
290293 const oldState = new CursorModelState ( this . _model , this ) ;
@@ -295,7 +298,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
295298
296299 this . _validateAutoClosedActions ( ) ;
297300
298- return this . _emitStateChangedIfNecessary ( source , reason , oldState ) ;
301+ return this . _emitStateChangedIfNecessary ( source , reason , oldState , reachedMaxCursorCount ) ;
299302 }
300303
301304 public setColumnSelectData ( columnSelectData : IColumnSelectData ) : void {
@@ -390,7 +393,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
390393 this . _cursors . dispose ( ) ;
391394 this . _cursors = new CursorCollection ( this . context ) ;
392395 this . _validateAutoClosedActions ( ) ;
393- this . _emitStateChangedIfNecessary ( 'model' , CursorChangeReason . ContentFlush , null ) ;
396+ this . _emitStateChangedIfNecessary ( 'model' , CursorChangeReason . ContentFlush , null , false ) ;
394397 } else {
395398 if ( this . _hasFocus && e . resultingSelection && e . resultingSelection . length > 0 ) {
396399 const cursorState = CursorState . fromModelSelections ( e . resultingSelection ) ;
@@ -524,7 +527,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
524527 // -----------------------------------------------------------------------------------------------------------
525528 // ----- emitting events
526529
527- private _emitStateChangedIfNecessary ( source : string | null | undefined , reason : CursorChangeReason , oldState : CursorModelState | null ) : boolean {
530+ private _emitStateChangedIfNecessary ( source : string | null | undefined , reason : CursorChangeReason , oldState : CursorModelState | null , reachedMaxCursorCount : boolean ) : boolean {
528531 const newState = new CursorModelState ( this . _model , this ) ;
529532 if ( newState . equals ( oldState ) ) {
530533 return false ;
@@ -543,7 +546,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
543546 ) {
544547 const oldSelections = oldState ? oldState . cursorState . map ( s => s . modelState . selection ) : null ;
545548 const oldModelVersionId = oldState ? oldState . modelVersionId : 0 ;
546- this . _onDidChange . fire ( new CursorStateChangedEvent ( selections , newState . modelVersionId , oldSelections , oldModelVersionId , source || 'keyboard' , reason ) ) ;
549+ this . _onDidChange . fire ( new CursorStateChangedEvent ( selections , newState . modelVersionId , oldSelections , oldModelVersionId , source || 'keyboard' , reason , reachedMaxCursorCount ) ) ;
547550 }
548551
549552 return true ;
@@ -683,7 +686,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
683686 this . _isHandling = false ;
684687 this . _cursors . startTrackingSelections ( ) ;
685688 this . _validateAutoClosedActions ( ) ;
686- if ( this . _emitStateChangedIfNecessary ( source , cursorChangeReason , oldState ) ) {
689+ if ( this . _emitStateChangedIfNecessary ( source , cursorChangeReason , oldState , false ) ) {
687690 this . _revealRange ( source , RevealTarget . Primary , viewEvents . VerticalRevealType . Simple , true , editorCommon . ScrollType . Smooth ) ;
688691 }
689692 }
0 commit comments