Skip to content

Commit 8a3f898

Browse files
committed
Move IPosition out of editorCommon
1 parent 5d6b0a5 commit 8a3f898

44 files changed

Lines changed: 156 additions & 144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/monaco/monaco.d.ts.recipe

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ declare module monaco {
4343
#include(vs/base/common/htmlContent): MarkedString
4444
#include(vs/base/browser/keyboardEvent): IKeyboardEvent
4545
#include(vs/base/browser/mouseEvent): IMouseEvent
46-
#include(vs/editor/common/editorCommon): IScrollEvent, IPosition, IRange, ISelection
47-
#include(vs/editor/common/core/position): Position
46+
#include(vs/editor/common/editorCommon): IScrollEvent, IRange, ISelection
47+
#include(vs/editor/common/core/position): IPosition, Position
4848
#include(vs/editor/common/core/range): Range
4949
#include(vs/editor/common/core/selection): Selection, SelectionDirection
5050
#include(vs/editor/common/core/token): Token

src/vs/editor/browser/editorBrowser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
99
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
1010
import { IConstructorSignature1 } from 'vs/platform/instantiation/common/instantiation';
1111
import * as editorCommon from 'vs/editor/common/editorCommon';
12-
import { Position } from 'vs/editor/common/core/position';
12+
import { Position, IPosition } from 'vs/editor/common/core/position';
1313
import { Range } from 'vs/editor/common/core/range';
1414
import { FastDomNode } from 'vs/base/browser/fastDomNode';
1515
import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents';
@@ -272,7 +272,7 @@ export interface IContentWidgetPosition {
272272
* Desired position for the content widget.
273273
* `preference` will also affect the placement.
274274
*/
275-
position: editorCommon.IPosition;
275+
position: IPosition;
276276
/**
277277
* Placement preference for position, in order of preference.
278278
*/
@@ -550,7 +550,7 @@ export interface ICodeEditor extends editorCommon.ICommonCodeEditor {
550550
* Explanation 2: the results of this method will not change if the container of the editor gets repositioned.
551551
* Warning: the results of this method are innacurate for positions that are outside the current editor viewport.
552552
*/
553-
getScrolledVisiblePosition(position: editorCommon.IPosition): { top: number; left: number; height: number; };
553+
getScrolledVisiblePosition(position: IPosition): { top: number; left: number; height: number; };
554554

555555
/**
556556
* Set the model ranges that will be hidden in the view.

src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77

88
import * as dom from 'vs/base/browser/dom';
99
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
10-
import * as editorCommon from 'vs/editor/common/editorCommon';
1110
import { ClassNames, ContentWidgetPositionPreference, IContentWidget } from 'vs/editor/browser/editorBrowser';
1211
import { ViewPart, PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart';
1312
import { ViewContext } from 'vs/editor/common/view/viewContext';
1413
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
15-
import { Position } from 'vs/editor/common/core/position';
14+
import { Position, IPosition } from 'vs/editor/common/core/position';
1615
import * as viewEvents from 'vs/editor/common/view/viewEvents';
1716

1817
interface IWidgetData {
1918
allowEditorOverflow: boolean;
2019
widget: IContentWidget;
21-
position: editorCommon.IPosition;
20+
position: IPosition;
2221
preference: ContentWidgetPositionPreference[];
2322
isVisible: boolean;
2423
domNode: FastDomNode<HTMLElement>;
@@ -184,7 +183,7 @@ export class ViewContentWidgets extends ViewPart {
184183
this.setShouldRender();
185184
}
186185

187-
public setWidgetPosition(widget: IContentWidget, position: editorCommon.IPosition, preference: ContentWidgetPositionPreference[]): void {
186+
public setWidgetPosition(widget: IContentWidget, position: IPosition, preference: ContentWidgetPositionPreference[]): void {
188187
let widgetData = this._widgets[widget.getId()];
189188

190189
widgetData.position = position;

src/vs/editor/browser/widget/codeEditorWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Event, { Emitter } from 'vs/base/common/event';
3030
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
3131
import { InternalEditorAction } from 'vs/editor/common/editorAction';
3232
import { IEditorOptions } from "vs/editor/common/config/editorOptions";
33+
import { IPosition } from "vs/editor/common/core/position";
3334

3435
export abstract class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.ICodeEditor {
3536

@@ -452,7 +453,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
452453
return this._view.getCodeEditorHelper().getTargetAtClientPoint(clientX, clientY);
453454
}
454455

455-
public getScrolledVisiblePosition(rawPosition: editorCommon.IPosition): { top: number; left: number; height: number; } {
456+
public getScrolledVisiblePosition(rawPosition: IPosition): { top: number; left: number; height: number; } {
456457
if (!this.hasView) {
457458
return null;
458459
}

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser';
2525
import { CodeEditor } from 'vs/editor/browser/codeEditor';
2626
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
2727
import { Configuration } from 'vs/editor/browser/config/configuration';
28-
import { Position } from 'vs/editor/common/core/position';
28+
import { Position, IPosition } from 'vs/editor/common/core/position';
2929
import { Selection } from 'vs/editor/common/core/selection';
3030
import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel';
3131
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
@@ -578,15 +578,15 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
578578
return this._domElement;
579579
}
580580

581-
public getVisibleColumnFromPosition(position: editorCommon.IPosition): number {
581+
public getVisibleColumnFromPosition(position: IPosition): number {
582582
return this.modifiedEditor.getVisibleColumnFromPosition(position);
583583
}
584584

585585
public getPosition(): Position {
586586
return this.modifiedEditor.getPosition();
587587
}
588588

589-
public setPosition(position: editorCommon.IPosition, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void {
589+
public setPosition(position: IPosition, reveal?: boolean, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void {
590590
this.modifiedEditor.setPosition(position, reveal, revealVerticalInCenter, revealHorizontal);
591591
}
592592

@@ -602,15 +602,15 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
602602
this.modifiedEditor.revealLineInCenterIfOutsideViewport(lineNumber);
603603
}
604604

605-
public revealPosition(position: editorCommon.IPosition, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
605+
public revealPosition(position: IPosition, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
606606
this.modifiedEditor.revealPosition(position, revealVerticalInCenter, revealHorizontal);
607607
}
608608

609-
public revealPositionInCenter(position: editorCommon.IPosition): void {
609+
public revealPositionInCenter(position: IPosition): void {
610610
this.modifiedEditor.revealPositionInCenter(position);
611611
}
612612

613-
public revealPositionInCenterIfOutsideViewport(position: editorCommon.IPosition): void {
613+
public revealPositionInCenterIfOutsideViewport(position: IPosition): void {
614614
this.modifiedEditor.revealPositionInCenterIfOutsideViewport(position);
615615
}
616616

src/vs/editor/common/commonCodeEditor.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Cursor, CursorEventType } from 'vs/editor/common/controller/cursor';
1717
import { CursorColumns } from 'vs/editor/common/controller/cursorCommon';
1818
import { IViewModelHelper } from 'vs/editor/common/controller/oneCursor';
1919
import { EditorState } from 'vs/editor/common/core/editorState';
20-
import { Position } from 'vs/editor/common/core/position';
20+
import { Position, IPosition } from 'vs/editor/common/core/position';
2121
import { Range } from 'vs/editor/common/core/range';
2222
import { Selection } from 'vs/editor/common/core/selection';
2323
import * as editorCommon from 'vs/editor/common/editorCommon';
@@ -263,7 +263,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
263263

264264
protected abstract _getCompletelyVisibleViewRange(): Range;
265265

266-
public getVisibleColumnFromPosition(rawPosition: editorCommon.IPosition): number {
266+
public getVisibleColumnFromPosition(rawPosition: IPosition): number {
267267
if (!this.model) {
268268
return rawPosition.column;
269269
}
@@ -281,7 +281,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
281281
return this.cursor.getPosition().clone();
282282
}
283283

284-
public setPosition(position: editorCommon.IPosition, reveal: boolean = false, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
284+
public setPosition(position: IPosition, reveal: boolean = false, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
285285
if (!this.cursor) {
286286
return;
287287
}
@@ -342,31 +342,31 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
342342
);
343343
}
344344

345-
public revealPosition(position: editorCommon.IPosition, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
345+
public revealPosition(position: IPosition, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void {
346346
this._revealPosition(
347347
position,
348348
revealVerticalInCenter ? editorCommon.VerticalRevealType.Center : editorCommon.VerticalRevealType.Simple,
349349
revealHorizontal
350350
);
351351
}
352352

353-
public revealPositionInCenter(position: editorCommon.IPosition): void {
353+
public revealPositionInCenter(position: IPosition): void {
354354
this._revealPosition(
355355
position,
356356
editorCommon.VerticalRevealType.Center,
357357
true
358358
);
359359
}
360360

361-
public revealPositionInCenterIfOutsideViewport(position: editorCommon.IPosition): void {
361+
public revealPositionInCenterIfOutsideViewport(position: IPosition): void {
362362
this._revealPosition(
363363
position,
364364
editorCommon.VerticalRevealType.CenterIfOutsideViewport,
365365
true
366366
);
367367
}
368368

369-
private _revealPosition(position: editorCommon.IPosition, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void {
369+
private _revealPosition(position: IPosition, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void {
370370
if (!Position.isIPosition(position)) {
371371
throw new Error('Invalid arguments');
372372
}

src/vs/editor/common/controller/oneCursor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'use strict';
66

77
import { SingleCursorState, CursorConfiguration, ICursorSimpleModel, CursorState } from 'vs/editor/common/controller/cursorCommon';
8-
import { Position } from 'vs/editor/common/core/position';
8+
import { Position, IPosition } from 'vs/editor/common/core/position';
99
import { Range } from 'vs/editor/common/core/range';
1010
import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
1111
import * as editorCommon from 'vs/editor/common/editorCommon';
@@ -45,7 +45,7 @@ export class CursorContext {
4545
this._coordinatesConverter = viewModelHelper.coordinatesConverter;
4646
}
4747

48-
public validateModelPosition(position: editorCommon.IPosition): Position {
48+
public validateModelPosition(position: IPosition): Position {
4949
return this.model.validatePosition(position);
5050
}
5151

@@ -316,7 +316,7 @@ export class OneCursorOp {
316316

317317
// -------------------- START handlers that simply change cursor state
318318

319-
public static moveTo(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: editorCommon.IPosition, _viewPosition: editorCommon.IPosition): CursorState {
319+
public static moveTo(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: IPosition, _viewPosition: IPosition): CursorState {
320320
const position = context.validateModelPosition(_position);
321321
const viewPosition = (
322322
_viewPosition
@@ -742,7 +742,7 @@ export class OneCursorOp {
742742
));
743743
}
744744

745-
public static line(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: editorCommon.IPosition, _viewPosition: editorCommon.IPosition): CursorState {
745+
public static line(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: IPosition, _viewPosition: IPosition): CursorState {
746746
const position = context.validateModelPosition(_position);
747747
const viewPosition = (
748748
_viewPosition
@@ -801,7 +801,7 @@ export class OneCursorOp {
801801
}
802802
}
803803

804-
public static word(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: editorCommon.IPosition): CursorState {
804+
public static word(context: CursorContext, cursor: OneCursor, inSelectionMode: boolean, _position: IPosition): CursorState {
805805
const position = context.validateModelPosition(_position);
806806
return this._fromModelCursorState(context, cursor, WordOperations.word(context.config, context.model, cursor.modelState, inSelectionMode, position));
807807
}

src/vs/editor/common/core/position.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import { IPosition } from 'vs/editor/common/editorCommon';
7+
/**
8+
* A position in the editor. This interface is suitable for serialization.
9+
*/
10+
export interface IPosition {
11+
/**
12+
* line number (starts at 1)
13+
*/
14+
readonly lineNumber: number;
15+
/**
16+
* column (the first character in a line is between column 1 and column 2)
17+
*/
18+
readonly column: number;
19+
}
820

921
/**
1022
* A position in the editor.

src/vs/editor/common/core/range.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
'use strict';
77

8-
import { Position } from 'vs/editor/common/core/position';
9-
import { IPosition, IRange } from 'vs/editor/common/editorCommon';
8+
import { Position, IPosition } from 'vs/editor/common/core/position';
9+
import { IRange } from 'vs/editor/common/editorCommon';
1010

1111
/**
1212
* A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)

src/vs/editor/common/editorCommon.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ServicesAccessor, IConstructorSignature1 } from 'vs/platform/instantiat
1313
import { LanguageId, LanguageIdentifier, StandardTokenType } from 'vs/editor/common/modes';
1414
import { LineTokens } from 'vs/editor/common/core/lineTokens';
1515
import { IDisposable } from 'vs/base/common/lifecycle';
16-
import { Position } from 'vs/editor/common/core/position';
16+
import { Position, IPosition } from 'vs/editor/common/core/position';
1717
import { Range } from 'vs/editor/common/core/range';
1818
import { Selection } from 'vs/editor/common/core/selection';
1919
import { IndentRange } from 'vs/editor/common/model/indentRanges';
@@ -35,20 +35,6 @@ export interface Event<T> {
3535

3636
// --- position & range
3737

38-
/**
39-
* A position in the editor. This interface is suitable for serialization.
40-
*/
41-
export interface IPosition {
42-
/**
43-
* line number (starts at 1)
44-
*/
45-
readonly lineNumber: number;
46-
/**
47-
* column (the first character in a line is between column 1 and column 2)
48-
*/
49-
readonly column: number;
50-
}
51-
5238
/**
5339
* A range in the editor. This interface is suitable for serialization.
5440
*/

0 commit comments

Comments
 (0)