未验证 提交 662ea121 编写于 作者: R rebornix

NotebookCellRange is now NotebookRange.

上级 ebb0a716
......@@ -1079,7 +1079,7 @@ declare module 'vscode' {
* @param range A notebook range.
* @returns The cells contained by the range or all cells.
*/
getCells(range?: NotebookCellRange): NotebookCell[];
getCells(range?: NotebookRange): NotebookCell[];
/**
* Save the document. The saving will be handled by the corresponding content provider
......@@ -1091,9 +1091,7 @@ declare module 'vscode' {
save(): Thenable<boolean>;
}
// todo@API RENAME to NotebookRange
// todo@API maybe have a NotebookCellPosition sibling
export class NotebookCellRange {
export class NotebookRange {
readonly start: number;
/**
* exclusive
......@@ -1104,7 +1102,7 @@ declare module 'vscode' {
constructor(start: number, end: number);
with(change: { start?: number, end?: number }): NotebookCellRange;
with(change: { start?: number, end?: number }): NotebookRange;
}
export enum NotebookEditorRevealType {
......@@ -1140,14 +1138,14 @@ declare module 'vscode' {
*
* The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
*/
readonly selections: NotebookCellRange[];
readonly selections: NotebookRange[];
/**
* The current visible ranges in the editor (vertically).
*/
readonly visibleRanges: NotebookCellRange[];
readonly visibleRanges: NotebookRange[];
revealRange(range: NotebookCellRange, revealType?: NotebookEditorRevealType): void;
revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;
/**
* The column in which this editor shows.
......@@ -1194,12 +1192,12 @@ declare module 'vscode' {
export interface NotebookEditorSelectionChangeEvent {
readonly notebookEditor: NotebookEditor;
readonly selections: ReadonlyArray<NotebookCellRange>
readonly selections: ReadonlyArray<NotebookRange>
}
export interface NotebookEditorVisibleRangesChangeEvent {
readonly notebookEditor: NotebookEditor;
readonly visibleRanges: ReadonlyArray<NotebookCellRange>;
readonly visibleRanges: ReadonlyArray<NotebookRange>;
}
export interface NotebookCellExecutionStateChangeEvent {
......@@ -1272,7 +1270,7 @@ declare module 'vscode' {
viewColumn?: ViewColumn;
preserveFocus?: boolean;
preview?: boolean;
selections?: NotebookCellRange[];
selections?: NotebookRange[];
}
export namespace notebook {
......@@ -1595,7 +1593,7 @@ declare module 'vscode' {
* createNotebookCellExecutionTask has not been called by the time the promise returned by this method is
* resolved, the cell will be put back into the Idle state.
*/
executeCellsRequest(document: NotebookDocument, ranges: NotebookCellRange[]): Thenable<void>;
executeCellsRequest(document: NotebookDocument, ranges: NotebookRange[]): Thenable<void>;
}
export interface NotebookCellExecuteStartContext {
......@@ -1701,7 +1699,7 @@ declare module 'vscode' {
//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorDecorationType
export interface NotebookEditor {
setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookCellRange): void;
setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookRange): void;
}
export interface NotebookDecorationRenderOptions {
......
......@@ -1244,7 +1244,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
SourceControlInputBoxValidationType: extHostTypes.SourceControlInputBoxValidationType,
ExtensionRuntime: extHostTypes.ExtensionRuntime,
TimelineItem: extHostTypes.TimelineItem,
NotebookCellRange: extHostTypes.NotebookCellRange,
NotebookRange: extHostTypes.NotebookRange,
NotebookCellKind: extHostTypes.NotebookCellKind,
NotebookCellExecutionState: extHostTypes.NotebookCellExecutionState,
NotebookDocumentMetadata: extHostTypes.NotebookDocumentMetadata,
......
......@@ -172,7 +172,7 @@ export class ExtHostNotebookKernelProviderAdapter extends Disposable {
return;
}
const extCellRange = cellRange.map(c => typeConverters.NotebookCellRange.to(c));
const extCellRange = cellRange.map(c => typeConverters.NotebookRange.to(c));
return kernel.executeCellsRequest(document.notebookDocument, extCellRange);
}
......@@ -468,7 +468,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
resolvedOptions = {
position: typeConverters.ViewColumn.from(options.viewColumn),
preserveFocus: options.preserveFocus,
selections: options.selections && options.selections.map(typeConverters.NotebookCellRange.from),
selections: options.selections && options.selections.map(typeConverters.NotebookRange.from),
pinned: typeof options.preview === 'boolean' ? !options.preview : undefined
};
} else {
......@@ -711,10 +711,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
// ONE: make all state updates
if (data.visibleRanges) {
editor._acceptVisibleRanges(data.visibleRanges.ranges.map(typeConverters.NotebookCellRange.to));
editor._acceptVisibleRanges(data.visibleRanges.ranges.map(typeConverters.NotebookRange.to));
}
if (data.selections) {
editor._acceptSelections(data.selections.selections.map(typeConverters.NotebookCellRange.to));
editor._acceptSelections(data.selections.selections.map(typeConverters.NotebookRange.to));
}
// TWO: send all events after states have been updated
......@@ -769,8 +769,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
editorId,
this._notebookEditorsProxy,
document,
data.visibleRanges.map(typeConverters.NotebookCellRange.to),
data.selections.map(typeConverters.NotebookCellRange.to),
data.visibleRanges.map(typeConverters.NotebookRange.to),
data.selections.map(typeConverters.NotebookRange.to),
typeof data.viewColumn === 'number' ? typeConverters.ViewColumn.to(data.viewColumn) : undefined
);
......
......@@ -227,7 +227,7 @@ export class ExtHostNotebookDocument {
}
}
private _validateRange(range: vscode.NotebookCellRange): vscode.NotebookCellRange {
private _validateRange(range: vscode.NotebookRange): vscode.NotebookRange {
if (range.start < 0) {
range = range.with({ start: 0 });
}
......@@ -237,7 +237,7 @@ export class ExtHostNotebookDocument {
return range;
}
private _getCells(range: vscode.NotebookCellRange): ExtHostCell[] {
private _getCells(range: vscode.NotebookRange): ExtHostCell[] {
range = this._validateRange(range);
const result: ExtHostCell[] = [];
for (let i = range.start; i < range.end; i++) {
......
......@@ -84,8 +84,8 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
export class ExtHostNotebookEditor {
private _selections: vscode.NotebookCellRange[] = [];
private _visibleRanges: vscode.NotebookCellRange[] = [];
private _selections: vscode.NotebookRange[] = [];
private _visibleRanges: vscode.NotebookRange[] = [];
private _viewColumn?: vscode.ViewColumn;
private _visible: boolean = false;
......@@ -99,8 +99,8 @@ export class ExtHostNotebookEditor {
readonly id: string,
private readonly _proxy: MainThreadNotebookEditorsShape,
readonly notebookData: ExtHostNotebookDocument,
visibleRanges: vscode.NotebookCellRange[],
selections: vscode.NotebookCellRange[],
visibleRanges: vscode.NotebookRange[],
selections: vscode.NotebookRange[],
viewColumn: vscode.ViewColumn | undefined
) {
this._selections = selections;
......@@ -124,7 +124,7 @@ export class ExtHostNotebookEditor {
revealRange(range, revealType) {
that._proxy.$tryRevealRange(
that.id,
extHostConverter.NotebookCellRange.from(range),
extHostConverter.NotebookRange.from(range),
revealType ?? extHostTypes.NotebookEditorRevealType.Default
);
},
......@@ -159,11 +159,11 @@ export class ExtHostNotebookEditor {
this._visible = value;
}
_acceptVisibleRanges(value: vscode.NotebookCellRange[]): void {
_acceptVisibleRanges(value: vscode.NotebookRange[]): void {
this._visibleRanges = value;
}
_acceptSelections(selections: vscode.NotebookCellRange[]): void {
_acceptSelections(selections: vscode.NotebookRange[]): void {
this._selections = selections;
}
......@@ -207,7 +207,7 @@ export class ExtHostNotebookEditor {
return this._proxy.$tryApplyEdits(this.id, editData.documentVersionId, compressedEdits);
}
setDecorations(decorationType: vscode.NotebookEditorDecorationType, range: vscode.NotebookCellRange): void {
setDecorations(decorationType: vscode.NotebookEditorDecorationType, range: vscode.NotebookRange): void {
if (range.isEmpty && !this._hasDecorationsForKey.has(decorationType.key)) {
// avoid no-op call to the renderer
return;
......@@ -220,7 +220,7 @@ export class ExtHostNotebookEditor {
return this._proxy.$trySetDecorations(
this.id,
extHostConverter.NotebookCellRange.from(range),
extHostConverter.NotebookRange.from(range),
decorationType.key
);
}
......
......@@ -199,7 +199,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
const cells: vscode.NotebookCell[] = [];
for (let range of ranges) {
cells.push(...document.notebookDocument.getCells(extHostTypeConverters.NotebookCellRange.to(range)));
cells.push(...document.notebookDocument.getCells(extHostTypeConverters.NotebookRange.to(range)));
}
try {
......
......@@ -1405,14 +1405,14 @@ export namespace LanguageSelector {
}
}
export namespace NotebookCellRange {
export namespace NotebookRange {
export function from(range: vscode.NotebookCellRange): notebooks.ICellRange {
export function from(range: vscode.NotebookRange): notebooks.ICellRange {
return { start: range.start, end: range.end };
}
export function to(range: notebooks.ICellRange): types.NotebookCellRange {
return new types.NotebookCellRange(range.start, range.end);
export function to(range: notebooks.ICellRange): types.NotebookRange {
return new types.NotebookRange(range.start, range.end);
}
}
......
......@@ -2895,7 +2895,7 @@ export enum ColorThemeKind {
//#region Notebook
export class NotebookCellRange {
export class NotebookRange {
private _start: number;
private _end: number;
......@@ -2923,7 +2923,7 @@ export class NotebookCellRange {
this._end = end;
}
with(change: { start?: number, end?: number }): NotebookCellRange {
with(change: { start?: number, end?: number }): NotebookRange {
let start = this._start;
let end = this._end;
......@@ -2936,7 +2936,7 @@ export class NotebookCellRange {
if (start === this._start && end === this._end) {
return this;
}
return new NotebookCellRange(start, end);
return new NotebookRange(start, end);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册