Skip to content

Commit cc99738

Browse files
committed
store title passed from jupyter to use as tab name
1 parent c59a7a2 commit cc99738

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
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() {

src/vs/workbench/services/workingCopy/common/workingCopyBackupService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ export abstract class WorkingCopyBackupService implements IWorkingCopyBackupServ
134134
if (backupWorkspaceHome) {
135135
return new WorkingCopyBackupServiceImpl(backupWorkspaceHome, this.fileService, this.logService);
136136
}
137-
138-
return new InMemoryWorkingCopyBackupService();
137+
else {
138+
return new WorkingCopyBackupServiceImpl(URI.file('c:\\temp\\backup'), this.fileService, this.logService);
139+
}
139140
}
140141

141142
reinitialize(backupWorkspaceHome: URI | undefined): void {

0 commit comments

Comments
 (0)