Skip to content

Untitled editors always saved on close when autosave is active #15501

Open
@colin-grant-work

Description

@colin-grant-work

Bug Description:

When autosave is active, untitled editors are exempted from it. When an untitled editor is closed, however, the logic to determine whether to save the widget or show a prompt to save the widget jumps straight to saving because autosave is on:

protected async closeWithSaving(widget: PostCreationSaveableWidget, options?: SaveableWidget.CloseOptions): Promise<void> {
const result = await this.shouldSaveWidget(widget, options);
if (typeof result === 'boolean') {
if (result) {
await this.save(widget, {
saveReason: SaveReason.AfterDelay
});
if (!Saveable.isDirty(widget)) {
await widget.closeWithoutSaving();
}
} else {
await widget.closeWithoutSaving();
}
}
}
protected async shouldSaveWidget(widget: PostCreationSaveableWidget, options?: SaveableWidget.CloseOptions): Promise<boolean | undefined> {
if (!Saveable.isDirty(widget)) {
return false;
}
if (this.autoSave !== 'off') {
return true;
}
const notLastWithDocument = !Saveable.closingWidgetWouldLoseSaveable(widget, Array.from(this.saveThrottles.keys()));
if (notLastWithDocument) {
await widget.closeWithoutSaving(false);
return undefined;
}
if (options && options.shouldSave) {
return options.shouldSave();
}
return new ShouldSaveDialog(widget).open();
}

Steps to Reproduce:

  1. Set the files.autoSave preference to anything but off
  2. Open an untitled editor.
  3. Write some content in the untitled editor, and then attempt to close it.
  4. A file picker dialog will open to pick the saving location.
  5. Cancel the save.
  6. The widget will still be open.
  7. Keep trying as long as your patience lasts.

Additional Information

  • Operating System: MacOS X Sequoia
  • Theia Version: 505c885

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions