提交 4807f833 编写于 作者: A Alex Dima

Move ISelection out of editorCommon

上级 4390b8f2
......@@ -43,10 +43,10 @@ declare module monaco {
#include(vs/base/common/htmlContent): MarkedString
#include(vs/base/browser/keyboardEvent): IKeyboardEvent
#include(vs/base/browser/mouseEvent): IMouseEvent
#include(vs/editor/common/editorCommon): IScrollEvent, ISelection
#include(vs/editor/common/editorCommon): IScrollEvent
#include(vs/editor/common/core/position): IPosition, Position
#include(vs/editor/common/core/range): IRange, Range
#include(vs/editor/common/core/selection): Selection, SelectionDirection
#include(vs/editor/common/core/selection): ISelection, Selection, SelectionDirection
#include(vs/editor/common/core/token): Token
}
......
......@@ -26,7 +26,7 @@ import { CodeEditor } from 'vs/editor/browser/codeEditor';
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { Configuration } from 'vs/editor/browser/config/configuration';
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes';
......@@ -624,13 +624,13 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
public setSelection(range: IRange, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(editorRange: Range, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(selection: editorCommon.ISelection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(selection: ISelection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(editorSelection: Selection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(something: any, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void {
this.modifiedEditor.setSelection(something, reveal, revealVerticalInCenter, revealHorizontal);
}
public setSelections(ranges: editorCommon.ISelection[]): void {
public setSelections(ranges: ISelection[]): void {
this.modifiedEditor.setSelections(ranges);
}
......
......@@ -19,7 +19,7 @@ import { IViewModelHelper } from 'vs/editor/common/controller/oneCursor';
import { EditorState } from 'vs/editor/common/core/editorState';
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Range, IRange } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { CharacterHardWrappingLineMapperFactory } from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
import { SplitLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection';
......@@ -399,7 +399,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
public setSelection(range: IRange, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(editorRange: Range, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(selection: editorCommon.ISelection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(selection: ISelection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(editorSelection: Selection, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void;
public setSelection(something: any, reveal: boolean = false, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
let isSelection = Selection.isISelection(something);
......@@ -410,10 +410,10 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
}
if (isSelection) {
this._setSelectionImpl(<editorCommon.ISelection>something, reveal, revealVerticalInCenter, revealHorizontal);
this._setSelectionImpl(<ISelection>something, reveal, revealVerticalInCenter, revealHorizontal);
} else if (isRange) {
// act as if it was an IRange
let selection: editorCommon.ISelection = {
let selection: ISelection = {
selectionStartLineNumber: something.startLineNumber,
selectionStartColumn: something.startColumn,
positionLineNumber: something.endLineNumber,
......@@ -423,7 +423,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
}
}
private _setSelectionImpl(sel: editorCommon.ISelection, reveal: boolean, revealVerticalInCenter: boolean, revealHorizontal: boolean): void {
private _setSelectionImpl(sel: ISelection, reveal: boolean, revealVerticalInCenter: boolean, revealHorizontal: boolean): void {
if (!this.cursor) {
return;
}
......@@ -514,7 +514,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
);
}
public setSelections(ranges: editorCommon.ISelection[]): void {
public setSelections(ranges: ISelection[]): void {
if (!this.cursor) {
return;
}
......
......@@ -14,7 +14,7 @@ import { CursorCollection, ICursorCollectionState } from 'vs/editor/common/contr
import { IViewModelHelper, OneCursor, OneCursorOp, CursorContext } from 'vs/editor/common/controller/oneCursor';
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 { Selection, SelectionDirection, ISelection } from 'vs/editor/common/core/selection';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { CursorColumns, EditOperationResult, CursorConfiguration } from 'vs/editor/common/controller/cursorCommon';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
......@@ -226,7 +226,7 @@ export class Cursor extends EventEmitter {
public restoreState(states: editorCommon.ICursorState[]): void {
var desiredSelections: editorCommon.ISelection[] = [],
var desiredSelections: ISelection[] = [],
state: editorCommon.ICursorState;
for (var i = 0; i < states.length; i++) {
......@@ -316,7 +316,7 @@ export class Cursor extends EventEmitter {
return this.cursors.getPosition(0);
}
public setSelections(source: string, selections: editorCommon.ISelection[]): void {
public setSelections(source: string, selections: ISelection[]): void {
this._onHandler('setSelections', (ctx: IMultipleCursorOperationContext) => {
ctx.shouldReveal = false;
this.cursors.setSelections(selections);
......
......@@ -5,8 +5,7 @@
'use strict';
import { IOneCursorState, OneCursor, CursorContext } from 'vs/editor/common/controller/oneCursor';
import { Selection } from 'vs/editor/common/core/selection';
import { ISelection } from 'vs/editor/common/editorCommon';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import { Position } from 'vs/editor/common/core/position';
import { CursorState } from 'vs/editor/common/controller/cursorCommon';
......
......@@ -7,7 +7,7 @@
import { SingleCursorState, CursorConfiguration, ICursorSimpleModel, CursorState } from 'vs/editor/common/controller/cursorCommon';
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
import { Selection, SelectionDirection, ISelection } from 'vs/editor/common/core/selection';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { MoveOperations } from 'vs/editor/common/controller/cursorMoveOperations';
import { WordOperations } from 'vs/editor/common/controller/cursorWordOperations';
......@@ -245,7 +245,7 @@ export class OneCursor {
context.model._removeMarker(this._selEndMarker);
}
public setSelection(context: CursorContext, selection: editorCommon.ISelection, viewSelection: editorCommon.ISelection = null): void {
public setSelection(context: CursorContext, selection: ISelection, viewSelection: ISelection = null): void {
let position = context.model.validatePosition({
lineNumber: selection.positionLineNumber,
column: selection.positionColumn
......
......@@ -5,7 +5,29 @@
'use strict';
import { Range } from 'vs/editor/common/core/range';
import { ISelection } from 'vs/editor/common/editorCommon';
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export interface ISelection {
/**
* The line number on which the selection has started.
*/
readonly selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
readonly selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
readonly positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
readonly positionColumn: number;
}
/**
* The direction of a selection.
......
......@@ -15,7 +15,7 @@ import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Range, IRange } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import { IndentRange } from 'vs/editor/common/model/indentRanges';
import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
......@@ -35,28 +35,6 @@ export interface Event<T> {
// --- position & range
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export interface ISelection {
/**
* The line number on which the selection has started.
*/
readonly selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
readonly selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
readonly positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
readonly positionColumn: number;
}
/**
* Vertical Lane in the overview ruler of the editor.
......
......@@ -14,8 +14,8 @@ import { ITextModelResolverService, ITextEditorModel } from 'vs/editor/common/se
import { IFileService, IFileChange } from 'vs/platform/files/common/files';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Range, IRange } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IIdentifiedSingleEditOperation, IModel, ISelection, EndOfLineSequence, ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import { IIdentifiedSingleEditOperation, IModel, EndOfLineSequence, ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { IProgressRunner } from 'vs/platform/progress/common/progress';
export interface IResourceEdit {
......
......@@ -16,11 +16,9 @@ import { CommonEditorRegistry, commonEditorContribution, EditorCommand } from 'v
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ISnippetVariableResolver, ICodeSnippet, CodeSnippet } from './snippet';
import { SnippetVariablesResolver } from './snippetVariables';
import EditorContextKeys = editorCommon.EditorContextKeys;
import { IPosition } from "vs/editor/common/core/position";
export class InsertSnippetController {
private editor: editorCommon.ICommonCodeEditor;
......@@ -336,15 +334,15 @@ export class InsertSnippetController {
}
private doLinkEditing(): void {
const selections: editorCommon.ISelection[] = [];
const selections: Selection[] = [];
for (let i = 0, len = this.trackedPlaceHolders[this.currentPlaceHolderIndex].ranges.length; i < len; i++) {
const range = this.model.getDecorationRange(this.trackedPlaceHolders[this.currentPlaceHolderIndex].ranges[i]);
selections.push({
selectionStartLineNumber: range.startLineNumber,
selectionStartColumn: range.startColumn,
positionLineNumber: range.endLineNumber,
positionColumn: range.endColumn
});
selections.push(new Selection(
range.startLineNumber,
range.startColumn,
range.endLineNumber,
range.endColumn
));
}
this.editor.setSelections(selections);
this.editor.revealRangeInCenterIfOutsideViewport(this.editor.getSelection());
......
......@@ -7,13 +7,14 @@
import * as assert from 'assert';
import { Cursor } from 'vs/editor/common/controller/cursor';
import { Position } from 'vs/editor/common/core/position';
import { Handler, ITextModelCreationOptions, CursorMovePosition, CursorMoveByUnit, ISelection } from 'vs/editor/common/editorCommon';
import { Handler, ITextModelCreationOptions, CursorMovePosition, CursorMoveByUnit } from 'vs/editor/common/editorCommon';
import { Model } from 'vs/editor/common/model/model';
import { IMode } from 'vs/editor/common/modes';
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
import { viewModelHelper as aViewModelHelper } from 'vs/editor/test/common/editorTestUtils';
import { IViewModelHelper } from 'vs/editor/common/controller/oneCursor';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IEditorOptions } from "vs/editor/common/config/editorOptions";
let H = Handler;
......@@ -544,7 +545,7 @@ function positionEqual(position: Position, lineNumber: number, column: number) {
assert.deepEqual(position, new Position(lineNumber, column), 'position equal');
}
function selectionEqual(selection: ISelection, posLineNumber: number, posColumn: number, selLineNumber: number, selColumn: number) {
function selectionEqual(selection: Selection, posLineNumber: number, posColumn: number, selLineNumber: number, selColumn: number) {
assert.deepEqual({
selectionStartLineNumber: selection.selectionStartLineNumber,
selectionStartColumn: selection.selectionStartColumn,
......
......@@ -413,29 +413,6 @@ declare module monaco {
readonly scrollWidthChanged: boolean;
readonly scrollHeightChanged: boolean;
}
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export interface ISelection {
/**
* The line number on which the selection has started.
*/
readonly selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
readonly selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
readonly positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
readonly positionColumn: number;
}
/**
* A position in the editor. This interface is suitable for serialization.
*/
......@@ -666,6 +643,29 @@ declare module monaco {
static spansMultipleLines(range: IRange): boolean;
}
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export interface ISelection {
/**
* The line number on which the selection has started.
*/
readonly selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
readonly selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
readonly positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
readonly positionColumn: number;
}
/**
* A selection in the editor.
* The selection is a range that has an orientation.
......
......@@ -41,6 +41,7 @@ import { TaskSet } from 'vs/workbench/parts/tasks/common/tasks';
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorModel2';
import { IPosition } from "vs/editor/common/core/position";
import { IRange } from "vs/editor/common/core/range";
import { ISelection } from "vs/editor/common/core/selection";
export interface IEnvironment {
enableProposedApi: boolean;
......@@ -140,7 +141,7 @@ export abstract class MainThreadEditorsShape {
$trySetOptions(id: string, options: ITextEditorConfigurationUpdate): TPromise<any> { throw ni(); }
$trySetDecorations(id: string, key: string, ranges: editorCommon.IDecorationOptions[]): TPromise<any> { throw ni(); }
$tryRevealRange(id: string, range: IRange, revealType: TextEditorRevealType): TPromise<any> { throw ni(); }
$trySetSelections(id: string, selections: editorCommon.ISelection[]): TPromise<any> { throw ni(); }
$trySetSelections(id: string, selections: ISelection[]): TPromise<any> { throw ni(); }
$tryApplyEdits(id: string, modelVersionId: number, edits: editorCommon.ISingleEditOperation[], opts: IApplyEditsOptions): TPromise<boolean> { throw ni(); }
$tryInsertSnippet(id: string, template: string, selections: IRange[], opts: IUndoStopOptions): TPromise<any> { throw ni(); }
$getDiffInformation(id: string): TPromise<editorCommon.ILineChange[]> { throw ni(); }
......@@ -326,7 +327,7 @@ export interface ITextEditorAddData {
id: string;
document: URI;
options: IResolvedTextEditorConfiguration;
selections: editorCommon.ISelection[];
selections: ISelection[];
editorPosition: EditorPosition;
}
export interface ITextEditorPositionData {
......
......@@ -8,12 +8,13 @@ import Severity from 'vs/base/common/severity';
import * as modes from 'vs/editor/common/modes';
import * as types from './extHostTypes';
import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
import { ISelection, IDecorationOptions, EndOfLineSequence } from 'vs/editor/common/editorCommon';
import { IDecorationOptions, EndOfLineSequence } from 'vs/editor/common/editorCommon';
import * as vscode from 'vscode';
import URI from 'vs/base/common/uri';
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import { IPosition } from "vs/editor/common/core/position";
import { IRange } from "vs/editor/common/core/range";
import { ISelection } from "vs/editor/common/core/selection";
export interface PositionLike {
line: number;
......
......@@ -10,7 +10,7 @@ import { IEditor } from 'vs/platform/editor/common/editor';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Range, IRange } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
import { SnippetController } from 'vs/editor/contrib/snippet/common/snippetController';
import { EndOfLine, TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes';
import { TextEditorCursorStyle, cursorStyleToString } from "vs/editor/common/config/editorOptions";
......@@ -195,7 +195,7 @@ export class MainThreadTextEditor {
return this._lastSelection;
}
public setSelections(selections: EditorCommon.ISelection[]): void {
public setSelections(selections: ISelection[]): void {
if (this._codeEditor) {
this._codeEditor.setSelections(selections);
return;
......
......@@ -8,7 +8,7 @@ import URI from 'vs/base/common/uri';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
import { ISingleEditOperation, ISelection, IDecorationRenderOptions, IDecorationOptions, ILineChange } from 'vs/editor/common/editorCommon';
import { ISingleEditOperation, IDecorationRenderOptions, IDecorationOptions, ILineChange } from 'vs/editor/common/editorCommon';
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
......@@ -19,6 +19,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { equals as objectEquals } from 'vs/base/common/objects';
import { ExtHostContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextEditorPositionData } from './extHost.protocol';
import { IRange } from "vs/editor/common/core/range";
import { ISelection } from "vs/editor/common/core/selection";
export class MainThreadEditors extends MainThreadEditorsShape {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册