提交 069bbd81 编写于 作者: J Johannes Rieken

type converters, use namespace for Selection

上级 6b4f8899
......@@ -95,7 +95,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
this._mainContext.getProxy(MainContext.MainThreadTextEditors),
data.id,
documentData,
data.selections.map(typeConverters.toSelection),
data.selections.map(typeConverters.Selection.to),
data.options,
data.visibleRanges.map(typeConverters.toRange),
typeConverters.toViewColumn(data.editorPosition)
......
......@@ -474,7 +474,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
}
private _trySetSelection(): TPromise<vscode.TextEditor> {
let selection = this._selections.map(TypeConverters.fromSelection);
let selection = this._selections.map(TypeConverters.Selection.from);
return this._runOnProxy(() => this._proxy.$trySetSelections(this._id, selection));
}
......
......@@ -123,7 +123,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
textEditor._acceptOptions(data.options);
}
if (data.selections) {
const selections = data.selections.selections.map(TypeConverters.toSelection);
const selections = data.selections.selections.map(TypeConverters.Selection.to);
textEditor._acceptSelections(selections);
}
if (data.visibleRanges) {
......@@ -140,7 +140,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
}
if (data.selections) {
const kind = TextEditorSelectionChangeKind.fromValue(data.selections.source);
const selections = data.selections.selections.map(TypeConverters.toSelection);
const selections = data.selections.selections.map(TypeConverters.Selection.to);
this._onDidChangeTextEditorSelection.fire({
textEditor,
selections,
......
......@@ -36,22 +36,24 @@ export interface SelectionLike extends RangeLike {
anchor: PositionLike;
active: PositionLike;
}
export namespace Selection {
export function toSelection(selection: ISelection): types.Selection {
let { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn } = selection;
let start = new types.Position(selectionStartLineNumber - 1, selectionStartColumn - 1);
let end = new types.Position(positionLineNumber - 1, positionColumn - 1);
return new types.Selection(start, end);
}
export function to(selection: ISelection): types.Selection {
let { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn } = selection;
let start = new types.Position(selectionStartLineNumber - 1, selectionStartColumn - 1);
let end = new types.Position(positionLineNumber - 1, positionColumn - 1);
return new types.Selection(start, end);
}
export function fromSelection(selection: SelectionLike): ISelection {
let { anchor, active } = selection;
return {
selectionStartLineNumber: anchor.line + 1,
selectionStartColumn: anchor.character + 1,
positionLineNumber: active.line + 1,
positionColumn: active.character + 1
};
export function from(selection: SelectionLike): ISelection {
let { anchor, active } = selection;
return {
selectionStartLineNumber: anchor.line + 1,
selectionStartColumn: anchor.character + 1,
positionLineNumber: active.line + 1,
positionColumn: active.character + 1
};
}
}
export function fromRange(range: RangeLike): IRange {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册