Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class AutoSaveService implements IInteractiveWindowListener {
private save() {
this.clearTimeout();
const notebook = this.getNotebook();
if (notebook && notebook.isDirty) {
if (notebook && notebook.isDirty && !notebook.isUntitled) {
// Notify webview to perform a save.
this.postEmitter.fire({ message: InteractiveWindowMessages.DoSave, payload: undefined });
} else {
Expand Down
11 changes: 6 additions & 5 deletions src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
return this._file;
}

public get isUntitled(): boolean {
const baseName = path.basename(this.file.fsPath);
return baseName.includes(localize.DataScience.untitledNotebookFileName());
}
public dispose(): void {
super.dispose();
this.close().ignoreErrors();
Expand Down Expand Up @@ -713,18 +717,15 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
let isDirty = this._dirty;

// Ask user for a save as dialog if no title
const baseName = path.basename(this.file.fsPath);
const isUntitled = baseName.includes(localize.DataScience.untitledNotebookFileName());
if (isUntitled) {
if (this.isUntitled) {
const filtersKey = localize.DataScience.dirtyNotebookDialogFilter();
const filtersObject: { [name: string]: string[] } = {};
filtersObject[filtersKey] = ['ipynb'];
isDirty = true;

fileToSaveTo = await this.applicationShell.showSaveDialog({
saveLabel: localize.DataScience.dirtyNotebookDialogTitle(),
filters: filtersObject,
defaultUri: isUntitled ? undefined : this.file
filters: filtersObject
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/client/datascience/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ export interface INotebookEditor extends IInteractiveBase {
executed: Event<INotebookEditor>;
modified: Event<INotebookEditor>;
saved: Event<INotebookEditor>;
/**
* Is this notebook representing an untitled file which has never been saved yet.
*/
readonly isUntitled: boolean;
/**
* `true` if there are unpersisted changes.
*/
Expand Down