Skip to content

Commit

Permalink
slightly better uri for untitled notebooks, #121974
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed May 19, 2021
1 parent 52c8fce commit 9716c27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ export class MainThreadNotebookDocuments implements MainThreadNotebookDocumentsS
};
}

async $tryCreateNotebook(options: { viewType?: string, content?: NotebookDataDto }): Promise<UriComponents> {
async $tryCreateNotebook(options: { viewType: string, content?: NotebookDataDto }): Promise<UriComponents> {

// find a free URI for the untitled case
let uri: URI;
for (let counter = 1; ; counter++) {
let candidate = URI.from({ scheme: Schemas.untitled, path: `Untitled-Notebook-${counter}` });
let candidate = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter}`, query: options.viewType });
if (!this._notebookService.getNotebookTextModel(candidate)) {
uri = candidate;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ export interface MainThreadNotebookEditorsShape extends IDisposable {
}

export interface MainThreadNotebookDocumentsShape extends IDisposable {
$tryCreateNotebook(options: { viewType?: string, content?: NotebookDataDto }): Promise<UriComponents>;
$tryCreateNotebook(options: { viewType: string, content?: NotebookDataDto }): Promise<UriComponents>;
$tryOpenNotebook(uriComponents: UriComponents): Promise<UriComponents>;
$trySaveNotebook(uri: UriComponents): Promise<boolean>;
$applyEdits(resource: UriComponents, edits: IImmediateCellEditOperation[], computeUndoRedo?: boolean): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
return new NotebookEditorDecorationType(this._notebookEditorsProxy, options).value;
}

async createNotebookDocument(options: { viewType?: string, content?: vscode.NotebookData } = {}): Promise<URI> {
async createNotebookDocument(options: { viewType: string, content?: vscode.NotebookData }): Promise<URI> {
const canonicalUri = await this._notebookDocumentsProxy.$tryCreateNotebook({
viewType: options.viewType,
content: options.content && typeConverters.NotebookData.from(options.content)
Expand Down

0 comments on commit 9716c27

Please sign in to comment.