mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -8,16 +8,21 @@ import { SingleCursorState, CursorContext, CursorState } from 'vs/editor/common/
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
|
||||
import { TrackedRangeStickiness } from 'vs/editor/common/editorCommon';
|
||||
|
||||
export class OneCursor {
|
||||
|
||||
public modelState: SingleCursorState;
|
||||
public viewState: SingleCursorState;
|
||||
|
||||
private _selStartMarker: string;
|
||||
private _selEndMarker: string;
|
||||
private _selTrackedRange: string;
|
||||
|
||||
constructor(context: CursorContext) {
|
||||
this.modelState = null;
|
||||
this.viewState = null;
|
||||
|
||||
this._selTrackedRange = null;
|
||||
|
||||
this._setState(
|
||||
context,
|
||||
new SingleCursorState(new Range(1, 1, 1, 1), 0, new Position(1, 1), 0),
|
||||
@@ -26,8 +31,7 @@ export class OneCursor {
|
||||
}
|
||||
|
||||
public dispose(context: CursorContext): void {
|
||||
context.model._removeMarker(this._selStartMarker);
|
||||
context.model._removeMarker(this._selEndMarker);
|
||||
this._selTrackedRange = context.model._setTrackedRange(this._selTrackedRange, null, TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges);
|
||||
}
|
||||
|
||||
public asCursorState(): CursorState {
|
||||
@@ -35,14 +39,11 @@ export class OneCursor {
|
||||
}
|
||||
|
||||
public readSelectionFromMarkers(context: CursorContext): Selection {
|
||||
const start = context.model._getMarker(this._selStartMarker);
|
||||
const end = context.model._getMarker(this._selEndMarker);
|
||||
|
||||
const range = context.model._getTrackedRange(this._selTrackedRange);
|
||||
if (this.modelState.selection.getDirection() === SelectionDirection.LTR) {
|
||||
return new Selection(start.lineNumber, start.column, end.lineNumber, end.column);
|
||||
return new Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
|
||||
}
|
||||
|
||||
return new Selection(end.lineNumber, end.column, start.lineNumber, start.column);
|
||||
return new Selection(range.endLineNumber, range.endColumn, range.startLineNumber, range.startColumn);
|
||||
}
|
||||
|
||||
public ensureValidState(context: CursorContext): void {
|
||||
@@ -100,17 +101,6 @@ export class OneCursor {
|
||||
this.modelState = modelState;
|
||||
this.viewState = viewState;
|
||||
|
||||
this._selStartMarker = this._ensureMarker(context, this._selStartMarker, this.modelState.selection.startLineNumber, this.modelState.selection.startColumn, true);
|
||||
this._selEndMarker = this._ensureMarker(context, this._selEndMarker, this.modelState.selection.endLineNumber, this.modelState.selection.endColumn, false);
|
||||
}
|
||||
|
||||
private _ensureMarker(context: CursorContext, markerId: string, lineNumber: number, column: number, stickToPreviousCharacter: boolean): string {
|
||||
if (!markerId) {
|
||||
return context.model._addMarker(0, lineNumber, column, stickToPreviousCharacter);
|
||||
} else {
|
||||
context.model._changeMarker(markerId, lineNumber, column);
|
||||
context.model._changeMarkerStickiness(markerId, stickToPreviousCharacter);
|
||||
return markerId;
|
||||
}
|
||||
this._selTrackedRange = context.model._setTrackedRange(this._selTrackedRange, this.modelState.selection, TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user