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

NotebookCellRange is now NotebookRange.

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