* Cursor -> CursorsController
* OneCursor -> Cursor
This commit is contained in:
parent
261d075b4c
commit
7f93f38f7b
5 changed files with 20 additions and 17 deletions
|
@ -24,7 +24,7 @@ import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
|
|||
import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl';
|
||||
import { ViewUserInputEvents } from 'vs/editor/browser/view/viewUserInputEvents';
|
||||
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, filterValidationDecorations } from 'vs/editor/common/config/editorOptions';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import { CursorsController } from 'vs/editor/common/controller/cursor';
|
||||
import { CursorColumns } from 'vs/editor/common/controller/cursorCommon';
|
||||
import { CursorChangeReason, ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
|
@ -1540,7 +1540,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
break;
|
||||
case OutgoingViewModelEventKind.CursorStateChanged: {
|
||||
if (e.reachedMaxCursorCount) {
|
||||
this._notificationService.warn(nls.localize('cursors.maximum', "The number of cursors has been limited to {0}.", Cursor.MAX_CURSOR_COUNT));
|
||||
this._notificationService.warn(nls.localize('cursors.maximum', "The number of cursors has been limited to {0}.", CursorsController.MAX_CURSOR_COUNT));
|
||||
}
|
||||
|
||||
const positions: Position[] = [];
|
||||
|
|
|
@ -29,7 +29,7 @@ export class CursorModelState {
|
|||
public readonly modelVersionId: number;
|
||||
public readonly cursorState: CursorState[];
|
||||
|
||||
constructor(model: ITextModel, cursor: Cursor) {
|
||||
constructor(model: ITextModel, cursor: CursorsController) {
|
||||
this.modelVersionId = model.getVersionId();
|
||||
this.cursorState = cursor.getCursorStates();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class AutoClosedAction {
|
|||
}
|
||||
}
|
||||
|
||||
export class Cursor extends Disposable {
|
||||
export class CursorsController extends Disposable {
|
||||
|
||||
public static readonly MAX_CURSOR_COUNT = 10000;
|
||||
|
||||
|
@ -216,8 +216,8 @@ export class Cursor extends Disposable {
|
|||
|
||||
public setStates(eventsCollector: ViewModelEventsCollector, source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): boolean {
|
||||
let reachedMaxCursorCount = false;
|
||||
if (states !== null && states.length > Cursor.MAX_CURSOR_COUNT) {
|
||||
states = states.slice(0, Cursor.MAX_CURSOR_COUNT);
|
||||
if (states !== null && states.length > CursorsController.MAX_CURSOR_COUNT) {
|
||||
states = states.slice(0, CursorsController.MAX_CURSOR_COUNT);
|
||||
reachedMaxCursorCount = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CursorContext, CursorState, PartialCursorState } from 'vs/editor/common/controller/cursorCommon';
|
||||
import { OneCursor } from 'vs/editor/common/controller/oneCursor';
|
||||
import { Cursor } from 'vs/editor/common/controller/oneCursor';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
|
||||
|
@ -12,15 +12,15 @@ export class CursorCollection {
|
|||
|
||||
private context: CursorContext;
|
||||
|
||||
private primaryCursor: OneCursor;
|
||||
private secondaryCursors: OneCursor[];
|
||||
private primaryCursor: Cursor;
|
||||
private secondaryCursors: Cursor[];
|
||||
|
||||
// An index which identifies the last cursor that was added / moved (think Ctrl+drag)
|
||||
private lastAddedCursorIndex: number;
|
||||
|
||||
constructor(context: CursorContext) {
|
||||
this.context = context;
|
||||
this.primaryCursor = new OneCursor(context);
|
||||
this.primaryCursor = new Cursor(context);
|
||||
this.secondaryCursors = [];
|
||||
this.lastAddedCursorIndex = 0;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ export class CursorCollection {
|
|||
}
|
||||
|
||||
private _addSecondaryCursor(): void {
|
||||
this.secondaryCursors.push(new OneCursor(this.context));
|
||||
this.secondaryCursors.push(new Cursor(this.context));
|
||||
this.lastAddedCursorIndex = this.secondaryCursors.length;
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,8 @@ export class CursorCollection {
|
|||
this.secondaryCursors.splice(removeIndex, 1);
|
||||
}
|
||||
|
||||
private _getAll(): OneCursor[] {
|
||||
let result: OneCursor[] = [];
|
||||
private _getAll(): Cursor[] {
|
||||
let result: Cursor[] = [];
|
||||
result[0] = this.primaryCursor;
|
||||
for (let i = 0, len = this.secondaryCursors.length; i < len; i++) {
|
||||
result[i + 1] = this.secondaryCursors[i];
|
||||
|
|
|
@ -9,7 +9,10 @@ import { Range } from 'vs/editor/common/core/range';
|
|||
import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
|
||||
import { TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
|
||||
export class OneCursor {
|
||||
/**
|
||||
* Represents a single cursor.
|
||||
*/
|
||||
export class Cursor {
|
||||
|
||||
public modelState!: SingleCursorState;
|
||||
public viewState!: SingleCursorState;
|
||||
|
|
|
@ -26,7 +26,7 @@ import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecora
|
|||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { EditorTheme } from 'vs/editor/common/view/viewContext';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import { CursorsController } from 'vs/editor/common/controller/cursor';
|
||||
import { PartialCursorState, CursorState, IColumnSelectData, EditOperationType, CursorConfiguration } from 'vs/editor/common/controller/cursorCommon';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IWhitespaceChangeAccessor } from 'vs/editor/common/viewLayout/linesLayout';
|
||||
|
@ -52,7 +52,7 @@ export class ViewModel extends Disposable implements IViewModel {
|
|||
private readonly _lines: IViewModelLinesCollection;
|
||||
public readonly coordinatesConverter: ICoordinatesConverter;
|
||||
public readonly viewLayout: ViewLayout;
|
||||
private readonly _cursor: Cursor;
|
||||
private readonly _cursor: CursorsController;
|
||||
private readonly _decorations: ViewModelDecorations;
|
||||
|
||||
constructor(
|
||||
|
@ -103,7 +103,7 @@ export class ViewModel extends Disposable implements IViewModel {
|
|||
|
||||
this.coordinatesConverter = this._lines.createCoordinatesConverter();
|
||||
|
||||
this._cursor = this._register(new Cursor(model, this, this.coordinatesConverter, this.cursorConfig));
|
||||
this._cursor = this._register(new CursorsController(model, this, this.coordinatesConverter, this.cursorConfig));
|
||||
|
||||
this.viewLayout = this._register(new ViewLayout(this._configuration, this.getLineCount(), scheduleAtNextAnimationFrame));
|
||||
|
||||
|
|
Loading…
Reference in a new issue