Skip to content

Commit df22ab1

Browse files
authored
Merge pull request microsoft#188095 from microsoft/aamunger/IWTabName
store title passed from jupyter to use as tab name
2 parents f68405c + 581b805 commit df22ab1

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ registerAction2(class extends Action2 {
392392

393393
counter++;
394394
} while (existingNotebookDocument.has(notebookUri.toString()));
395+
InteractiveEditorInput.setName(notebookUri, title);
395396

396397
logService.debug('Open new interactive window:', notebookUri.toString(), inputUri.toString());
397398

src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
2525
return instantiationService.createInstance(InteractiveEditorInput, resource, inputResource, title, language);
2626
}
2727

28+
private static windowNames: Record<string, string> = {};
29+
30+
static setName(notebookUri: URI, title: string | undefined) {
31+
if (title) {
32+
this.windowNames[notebookUri.path] = title;
33+
}
34+
}
35+
2836
static readonly ID: string = 'workbench.input.interactive';
2937

3038
public override get editorId(): string {
@@ -35,7 +43,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
3543
return InteractiveEditorInput.ID;
3644
}
3745

38-
private _initTitle?: string;
46+
private name: string;
3947

4048
get language() {
4149
return this._inputModelRef?.object.textEditorModel.getLanguageId() ?? this._initLanguage;
@@ -91,7 +99,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
9199
super();
92100
this._notebookEditorInput = input;
93101
this._register(this._notebookEditorInput);
94-
this._initTitle = title;
102+
this.name = title ?? InteractiveEditorInput.windowNames[resource.path] ?? paths.basename(resource.path, paths.extname(resource.path));
95103
this._initLanguage = languageId;
96104
this._resource = resource;
97105
this._inputResource = inputResource;
@@ -209,14 +217,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
209217
}
210218

211219
override getName() {
212-
if (this._initTitle) {
213-
return this._initTitle;
214-
}
215-
216-
const p = this.primary.resource!.path;
217-
const basename = paths.basename(p);
218-
219-
return basename.substr(0, basename.length - paths.extname(p).length);
220+
return this.name;
220221
}
221222

222223
override isModified() {

0 commit comments

Comments
 (0)