Skip to content

Commit

Permalink
Refine notebookEditor proposal (microsoft#149656)
Browse files Browse the repository at this point in the history
For microsoft#149271

- `NotebookEditor.document` -> `NotebookEditor.notebook`

- Add `selection` to for setting primary selections. Matches `TextDocument.selection`

- Deprecate `showNotebookDocument`
  • Loading branch information
mjbvz authored and Mingpan committed May 23, 2022
1 parent 7b29cee commit 453f640
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/vs/workbench/api/common/extHostNotebookEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ export class ExtHostNotebookEditor {
get document() {
return that.notebookData.apiNotebook;
},
get notebook() {
return that.notebookData.apiNotebook;
},
get selection() {
return that._selections[0];
},
set selection(selection: vscode.NotebookRange) {
this.selections = [selection];
},
get selections() {
return that._selections;
},
Expand Down
26 changes: 20 additions & 6 deletions src/vscode-dts/vscode.proposed.notebookEditor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ declare module 'vscode' {
export interface NotebookEditor {
/**
* The document associated with this notebook editor.
*
* @deprecated Use {@linkcode NotebookEditor.notebook} instead.
*/
readonly document: NotebookDocument;

/**
* The selections on this notebook editor.
* The {@link NotebookDocument notebook document} associated with this notebook editor.
*/
readonly notebook: NotebookDocument;

/**
* The primary selection in this notebook editor.
*/
selection: NotebookRange;

/**
* All selections in this notebook editor.
*
* The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
*/
Expand All @@ -54,18 +66,18 @@ declare module 'vscode' {
*/
readonly visibleRanges: readonly NotebookRange[];

/**
* The column in which this editor shows.
*/
readonly viewColumn?: ViewColumn;

/**
* Scroll as indicated by `revealType` in order to reveal the given range.
*
* @param range A range.
* @param revealType The scrolling strategy for revealing `range`.
*/
revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;

/**
* The column in which this editor shows.
*/
readonly viewColumn?: ViewColumn;
}

/**
Expand Down Expand Up @@ -180,6 +192,8 @@ declare module 'vscode' {
/**
* A short-hand for `openNotebookDocument(uri).then(document => showNotebookDocument(document, options))`.
*
* @deprecated Will not be finalized.
*
* @see {@link workspace.openNotebookDocument}
*
* @param uri The resource to open.
Expand Down

0 comments on commit 453f640

Please sign in to comment.