Skip to content

Commit 1c816b0

Browse files
committed
include scratchpads for save all on shutdown
1 parent e3351e2 commit 1c816b0

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

src/vs/workbench/common/editor/editorInput.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ export abstract class EditorInput extends AbstractEditorInput {
185185
return false;
186186
}
187187

188+
/**
189+
* Returns if the input has unsaved changes.
190+
*/
191+
isModified(): boolean {
192+
return this.isDirty();
193+
}
194+
188195
/**
189196
* Returns if this input is currently being saved or soon to be
190197
* saved. Based on this assumption the editor may for example

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
219219
return basename.substr(0, basename.length - paths.extname(p).length);
220220
}
221221

222+
override isModified() {
223+
return true;
224+
}
225+
222226
override dispose() {
223227
// we support closing the interactive window without prompt, so the editor model should not be dirty
224228
this._editorModelReference?.revert({ soft: true });

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
980980
}
981981

982982
saveAll(options?: ISaveAllEditorsOptions): Promise<ISaveEditorsResult> {
983-
return this.save(this.getAllDirtyEditors(options), options);
983+
return this.save(this.getAllModifiedEditors(options), options);
984984
}
985985

986986
async revert(editors: IEditorIdentifier | IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> {
@@ -1006,15 +1006,19 @@ export class EditorService extends Disposable implements EditorServiceImpl {
10061006
}
10071007

10081008
async revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> {
1009-
return this.revert(this.getAllDirtyEditors(options), options);
1009+
return this.revert(this.getAllModifiedEditors(options), options);
10101010
}
10111011

1012-
private getAllDirtyEditors(options?: IBaseSaveRevertAllEditorOptions): IEditorIdentifier[] {
1012+
private getAllModifiedEditors(options?: IBaseSaveRevertAllEditorOptions): IEditorIdentifier[] {
10131013
const editors: IEditorIdentifier[] = [];
10141014

10151015
for (const group of this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE)) {
10161016
for (const editor of group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)) {
1017-
if (!editor.isDirty()) {
1017+
if (!editor.isModified()) {
1018+
continue;
1019+
}
1020+
1021+
if (!options?.includeScratchpad && editor.hasCapability(EditorInputCapabilities.Scratchpad)) {
10181022
continue;
10191023
}
10201024

src/vs/workbench/services/editor/common/editorService.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ export interface IBaseSaveRevertAllEditorOptions {
8282
*/
8383
readonly includeUntitled?: boolean;
8484

85+
/**
86+
* Whether to include scratchpad editors.
87+
* if set to true, `includeUntitled` should also be true.
88+
*/
89+
readonly includeScratchpad?: boolean;
90+
8591
/**
8692
* Whether to exclude sticky editors.
8793
*/

src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
323323

324324
let result: boolean | undefined = undefined;
325325
if (typeof arg1 === 'boolean' || modifiedWorkingCopies.length === this.workingCopyService.modifiedCount) {
326-
result = (await this.editorService.saveAll({ includeUntitled: typeof arg1 === 'boolean' ? arg1 : true, ...saveOptions })).success;
326+
result = (await this.editorService.saveAll({
327+
includeScratchpad: true,
328+
includeUntitled: typeof arg1 === 'boolean' ? arg1 : true,
329+
...saveOptions
330+
})).success;
327331
}
328332

329333
// If we still have modified working copies, save those directly

0 commit comments

Comments
 (0)