Skip to content

Commit 8076a19

Browse files
committed
debug: save all untitled non dirty files before debug start
fixes #21681
1 parent 540a11e commit 8076a19

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

src/vs/workbench/parts/debug/browser/debugActions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IFileService } from 'vs/platform/files/common/files';
1515
import { IDebugService, IConfig, State, IProcess, IThread, IEnablement, IBreakpoint, IStackFrame, IFunctionBreakpoint, IDebugEditorContribution, EDITOR_CONTRIBUTION_ID, IExpression, REPL_ID }
1616
from 'vs/workbench/parts/debug/common/debug';
1717
import { Variable, Expression, Thread, Breakpoint, Process } from 'vs/workbench/parts/debug/common/debugModel';
18+
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
1819
import { IPartService } from 'vs/workbench/services/part/common/partService';
1920
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
2021
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -118,7 +119,8 @@ export class StartAction extends AbstractDebugAction {
118119
@IKeybindingService keybindingService: IKeybindingService,
119120
@ICommandService private commandService: ICommandService,
120121
@IWorkspaceContextService private contextService: IWorkspaceContextService,
121-
@IFileService private fileService: IFileService
122+
@IFileService private fileService: IFileService,
123+
@ITextFileService private textFileService: ITextFileService
122124
) {
123125
super(id, label, 'debug-action start', debugService, keybindingService);
124126
this.debugService.getViewModel().onDidSelectConfiguration(() => {
@@ -127,7 +129,7 @@ export class StartAction extends AbstractDebugAction {
127129
}
128130

129131
public run(): TPromise<any> {
130-
return this.commandService.executeCommand('workbench.action.files.saveIfDirty').then(() => {
132+
return this.textFileService.saveAll().then(() => {
131133
if (this.debugService.getModel().getProcesses().length === 0) {
132134
this.debugService.removeReplExpressions();
133135
}
@@ -193,9 +195,10 @@ export class RunAction extends StartAction {
193195
@IKeybindingService keybindingService: IKeybindingService,
194196
@ICommandService commandService: ICommandService,
195197
@IWorkspaceContextService contextService: IWorkspaceContextService,
196-
@IFileService fileService: IFileService
198+
@IFileService fileService: IFileService,
199+
@ITextFileService textFileService: ITextFileService
197200
) {
198-
super(id, label, debugService, keybindingService, commandService, contextService, fileService);
201+
super(id, label, debugService, keybindingService, commandService, contextService, fileService, textFileService);
199202
}
200203

201204
protected getDefaultConfiguration(): any {

src/vs/workbench/parts/files/browser/fileActions.contribution.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isMacintosh } from 'vs/base/common/platform';
1111
import { ActionItem, BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
1212
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor } from 'vs/workbench/browser/actionBarRegistry';
1313
import { IEditorInputActionContext, IEditorInputAction, EditorInputActionContributor } from 'vs/workbench/browser/parts/editor/baseEditor';
14-
import { GlobalNewUntitledFileAction, SaveFileAsAction, OpenFileAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveIfDirtyFileAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView } from 'vs/workbench/parts/files/browser/fileActions';
14+
import { GlobalNewUntitledFileAction, SaveFileAsAction, OpenFileAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView } from 'vs/workbench/parts/files/browser/fileActions';
1515
import { RevertLocalChangesAction, AcceptLocalChangesAction, CONFLICT_RESOLUTION_SCHEME } from 'vs/workbench/parts/files/browser/saveErrorHandler';
1616
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
1717
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
@@ -213,7 +213,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalCopyPathAction,
213213
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAction, SaveFileAction.ID, SaveFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_S }), 'Files: Save', category);
214214
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveAllAction, SaveAllAction.ID, SaveAllAction.LABEL, { primary: void 0, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_S }, win: { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_S) } }), 'Files: Save All', category);
215215
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFilesAction, SaveFilesAction.ID, null /* only for programmatic trigger */), null);
216-
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveIfDirtyFileAction, SaveIfDirtyFileAction.ID, null /* only for programmatic trigger */), null);
217216
registry.registerWorkbenchAction(new SyncActionDescriptor(RevertFileAction, RevertFileAction.ID, RevertFileAction.LABEL), 'Files: Revert File', category);
218217
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFileAction, GlobalNewFileAction.ID, GlobalNewFileAction.LABEL), 'Files: New File', category);
219218
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFolderAction, GlobalNewFolderAction.ID, GlobalNewFolderAction.LABEL), 'Files: New Folder', category);

src/vs/workbench/parts/files/browser/fileActions.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
13411341
}
13421342

13431343
public abstract isSaveAs(): boolean;
1344-
protected abstract isForce(): boolean;
13451344

13461345
public setResource(resource: URI): void {
13471346
this.resource = resource;
@@ -1424,27 +1423,13 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
14241423
}
14251424

14261425
// Just save
1427-
return this.textFileService.save(source, { force: this.isForce() /* force a change to the file to trigger external watchers if any */ });
1426+
return this.textFileService.save(source, { force: true /* force a change to the file to trigger external watchers if any */ });
14281427
}
14291428

14301429
return TPromise.as(false);
14311430
}
14321431
}
14331432

1434-
export class SaveIfDirtyFileAction extends BaseSaveFileAction {
1435-
1436-
public static ID = 'workbench.action.files.saveIfDirty';
1437-
public static LABEL = nls.localize('saveIfDirty', "Save If Dirty");
1438-
1439-
public isSaveAs(): boolean {
1440-
return false;
1441-
}
1442-
1443-
protected isForce(): boolean {
1444-
return false;
1445-
}
1446-
}
1447-
14481433
export class SaveFileAction extends BaseSaveFileAction {
14491434

14501435
public static ID = 'workbench.action.files.save';
@@ -1453,10 +1438,6 @@ export class SaveFileAction extends BaseSaveFileAction {
14531438
public isSaveAs(): boolean {
14541439
return false;
14551440
}
1456-
1457-
protected isForce(): boolean {
1458-
return true;
1459-
}
14601441
}
14611442

14621443
export class SaveFileAsAction extends BaseSaveFileAction {
@@ -1467,10 +1448,6 @@ export class SaveFileAsAction extends BaseSaveFileAction {
14671448
public isSaveAs(): boolean {
14681449
return true;
14691450
}
1470-
1471-
protected isForce(): boolean {
1472-
return true;
1473-
}
14741451
}
14751452

14761453
export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {

0 commit comments

Comments
 (0)