Skip to content

Commit 361a8c7

Browse files
committed
Rename reveal type to match its behavior more
1 parent 9edb956 commit 361a8c7

9 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/vs/editor/browser/viewParts/lines/viewLines.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
589589
if (boxEndY - boxStartY > viewportHeight) {
590590
// the box is larger than the viewport ... scroll to its top
591591
newScrollTop = boxStartY;
592-
} else if (verticalType === viewEvents.VerticalRevealType.Definition) {
592+
} else if (verticalType === viewEvents.VerticalRevealType.NearTop) {
593593
// We want a gap that is 20% of the viewport, but with a minimum of 5 lines
594594
const desiredGapAbove = Math.max(5 * this._lineHeight, viewportHeight * 0.2);
595595
// Try to scroll just above the box with the desired gap

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
557557
this._revealLine(lineNumber, VerticalRevealType.CenterIfOutsideViewport, scrollType);
558558
}
559559

560-
public revealLineAtDefinition(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
561-
this._revealLine(lineNumber, VerticalRevealType.Definition, scrollType);
560+
public revealLineNearTop(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
561+
this._revealLine(lineNumber, VerticalRevealType.NearTop, scrollType);
562562
}
563563

564564
private _revealLine(lineNumber: number, revealType: VerticalRevealType, scrollType: editorCommon.ScrollType): void {
@@ -601,10 +601,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
601601
);
602602
}
603603

604-
public revealPositionAtDefinition(position: IPosition, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
604+
public revealPositionNearTop(position: IPosition, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
605605
this._revealPosition(
606606
position,
607-
VerticalRevealType.Definition,
607+
VerticalRevealType.NearTop,
608608
true,
609609
scrollType
610610
);
@@ -698,11 +698,11 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
698698
);
699699
}
700700

701-
public revealLinesAtDefinition(startLineNumber: number, endLineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
701+
public revealLinesNearTop(startLineNumber: number, endLineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
702702
this._revealLines(
703703
startLineNumber,
704704
endLineNumber,
705-
VerticalRevealType.Definition,
705+
VerticalRevealType.NearTop,
706706
scrollType
707707
);
708708
}
@@ -747,10 +747,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
747747
);
748748
}
749749

750-
public revealRangeAtDefinition(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
750+
public revealRangeNearTop(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
751751
this._revealRange(
752752
range,
753-
VerticalRevealType.Definition,
753+
VerticalRevealType.NearTop,
754754
true,
755755
scrollType
756756
);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
763763
this.modifiedEditor.revealLineInCenterIfOutsideViewport(lineNumber, scrollType);
764764
}
765765

766-
public revealLineAtDefinition(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
767-
this.modifiedEditor.revealLineAtDefinition(lineNumber, scrollType);
766+
public revealLineNearTop(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
767+
this.modifiedEditor.revealLineNearTop(lineNumber, scrollType);
768768
}
769769

770770
public revealPosition(position: IPosition, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
@@ -779,8 +779,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
779779
this.modifiedEditor.revealPositionInCenterIfOutsideViewport(position, scrollType);
780780
}
781781

782-
public revealPositionAtDefinition(position: IPosition, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
783-
this.modifiedEditor.revealPositionAtDefinition(position, scrollType);
782+
public revealPositionNearTop(position: IPosition, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
783+
this.modifiedEditor.revealPositionNearTop(position, scrollType);
784784
}
785785

786786
public getSelection(): Selection | null {
@@ -815,8 +815,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
815815
this.modifiedEditor.revealLinesInCenterIfOutsideViewport(startLineNumber, endLineNumber, scrollType);
816816
}
817817

818-
public revealLinesAtDefinition(startLineNumber: number, endLineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
819-
this.modifiedEditor.revealLinesAtDefinition(startLineNumber, endLineNumber, scrollType);
818+
public revealLinesNearTop(startLineNumber: number, endLineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
819+
this.modifiedEditor.revealLinesNearTop(startLineNumber, endLineNumber, scrollType);
820820
}
821821

822822
public revealRange(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = true): void {
@@ -831,8 +831,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
831831
this.modifiedEditor.revealRangeInCenterIfOutsideViewport(range, scrollType);
832832
}
833833

834-
public revealRangeAtDefinition(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
835-
this.modifiedEditor.revealRangeAtDefinition(range, scrollType);
834+
public revealRangeNearTop(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
835+
this.modifiedEditor.revealRangeNearTop(range, scrollType);
836836
}
837837

838838
public revealRangeAtTop(range: IRange, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {

src/vs/editor/common/editorCommon.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export interface IEditor {
359359
* Scroll vertically as necessary and reveal a line close to the top of the viewport,
360360
* optimized for viewing a code definition.
361361
*/
362-
revealLineAtDefinition(lineNumber: number, scrollType?: ScrollType): void;
362+
revealLineNearTop(lineNumber: number, scrollType?: ScrollType): void;
363363

364364
/**
365365
* Scroll vertically or horizontally as necessary and reveal a position.
@@ -380,7 +380,7 @@ export interface IEditor {
380380
* Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport,
381381
* optimized for viewing a code definition.
382382
*/
383-
revealPositionAtDefinition(position: IPosition, scrollType?: ScrollType): void;
383+
revealPositionNearTop(position: IPosition, scrollType?: ScrollType): void;
384384

385385
/**
386386
* Returns the primary selection of the editor.
@@ -438,7 +438,7 @@ export interface IEditor {
438438
* Scroll vertically as necessary and reveal lines close to the top of the viewport,
439439
* optimized for viewing a code definition.
440440
*/
441-
revealLinesAtDefinition(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
441+
revealLinesNearTop(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
442442

443443
/**
444444
* Scroll vertically or horizontally as necessary and reveal a range.
@@ -464,7 +464,7 @@ export interface IEditor {
464464
* Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
465465
* optimized for viewing a code definition.
466466
*/
467-
revealRangeAtDefinition(range: IRange, scrollType?: ScrollType): void;
467+
revealRangeNearTop(range: IRange, scrollType?: ScrollType): void;
468468

469469
/**
470470
* Directly trigger a handler or an editor action.

src/vs/editor/common/view/viewEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const enum VerticalRevealType {
184184
CenterIfOutsideViewport = 2,
185185
Top = 3,
186186
Bottom = 4,
187-
Definition = 5,
187+
NearTop = 5,
188188
}
189189

190190
export class ViewRevealRangeRequestEvent {

src/vs/monaco.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ declare namespace monaco.editor {
21752175
* Scroll vertically as necessary and reveal a line close to the top of the viewport,
21762176
* optimized for viewing a code definition.
21772177
*/
2178-
revealLineAtDefinition(lineNumber: number, scrollType?: ScrollType): void;
2178+
revealLineNearTop(lineNumber: number, scrollType?: ScrollType): void;
21792179
/**
21802180
* Scroll vertically or horizontally as necessary and reveal a position.
21812181
*/
@@ -2192,7 +2192,7 @@ declare namespace monaco.editor {
21922192
* Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport,
21932193
* optimized for viewing a code definition.
21942194
*/
2195-
revealPositionAtDefinition(position: IPosition, scrollType?: ScrollType): void;
2195+
revealPositionNearTop(position: IPosition, scrollType?: ScrollType): void;
21962196
/**
21972197
* Returns the primary selection of the editor.
21982198
*/
@@ -2242,7 +2242,7 @@ declare namespace monaco.editor {
22422242
* Scroll vertically as necessary and reveal lines close to the top of the viewport,
22432243
* optimized for viewing a code definition.
22442244
*/
2245-
revealLinesAtDefinition(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
2245+
revealLinesNearTop(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
22462246
/**
22472247
* Scroll vertically or horizontally as necessary and reveal a range.
22482248
*/
@@ -2263,7 +2263,7 @@ declare namespace monaco.editor {
22632263
* Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
22642264
* optimized for viewing a code definition.
22652265
*/
2266-
revealRangeAtDefinition(range: IRange, scrollType?: ScrollType): void;
2266+
revealRangeNearTop(range: IRange, scrollType?: ScrollType): void;
22672267
/**
22682268
* Directly trigger a handler or an editor action.
22692269
* @param source The source of the call.

src/vs/platform/editor/common/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const enum TextEditorSelectionRevealType {
227227
/**
228228
* Option to scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, but not quite at the top.
229229
*/
230-
Definition = 2,
230+
NearTop = 2,
231231
}
232232

233233
export interface ITextEditorOptions extends IEditorOptions {

src/vs/workbench/common/editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,8 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
12021202

12031203
editor.setSelection(range);
12041204

1205-
if (this.selectionRevealType === TextEditorSelectionRevealType.Definition) {
1206-
editor.revealRangeAtDefinition(range, scrollType);
1205+
if (this.selectionRevealType === TextEditorSelectionRevealType.NearTop) {
1206+
editor.revealRangeNearTop(range, scrollType);
12071207
} else if (this.selectionRevealType === TextEditorSelectionRevealType.CenterIfOutsideViewport) {
12081208
editor.revealRangeInCenterIfOutsideViewport(range, scrollType);
12091209
} else {

src/vs/workbench/contrib/outline/browser/outlinePane.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export class OutlinePane extends ViewPane {
630630
options: {
631631
preserveFocus: !focus,
632632
selection: Range.collapseToStart(element.symbol.selectionRange),
633-
selectionRevealType: TextEditorSelectionRevealType.Definition,
633+
selectionRevealType: TextEditorSelectionRevealType.NearTop,
634634
}
635635
} as IResourceInput, aside ? SIDE_GROUP : ACTIVE_GROUP);
636636
}

0 commit comments

Comments
 (0)