Skip to content

Commit

Permalink
debug: save all untitled non dirty files before debug start
Browse files Browse the repository at this point in the history
fixes #21681
  • Loading branch information
isidorn committed Mar 8, 2017
1 parent 540a11e commit 8076a19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
11 changes: 7 additions & 4 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { IDebugService, IConfig, State, IProcess, IThread, IEnablement, IBreakpoint, IStackFrame, IFunctionBreakpoint, IDebugEditorContribution, EDITOR_CONTRIBUTION_ID, IExpression, REPL_ID }
from 'vs/workbench/parts/debug/common/debug';
import { Variable, Expression, Thread, Breakpoint, Process } from 'vs/workbench/parts/debug/common/debugModel';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
Expand Down Expand Up @@ -118,7 +119,8 @@ export class StartAction extends AbstractDebugAction {
@IKeybindingService keybindingService: IKeybindingService,
@ICommandService private commandService: ICommandService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IFileService private fileService: IFileService
@IFileService private fileService: IFileService,
@ITextFileService private textFileService: ITextFileService
) {
super(id, label, 'debug-action start', debugService, keybindingService);
this.debugService.getViewModel().onDidSelectConfiguration(() => {
Expand All @@ -127,7 +129,7 @@ export class StartAction extends AbstractDebugAction {
}

public run(): TPromise<any> {
return this.commandService.executeCommand('workbench.action.files.saveIfDirty').then(() => {
return this.textFileService.saveAll().then(() => {
if (this.debugService.getModel().getProcesses().length === 0) {
this.debugService.removeReplExpressions();
}
Expand Down Expand Up @@ -193,9 +195,10 @@ export class RunAction extends StartAction {
@IKeybindingService keybindingService: IKeybindingService,
@ICommandService commandService: ICommandService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IFileService fileService: IFileService
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService
) {
super(id, label, debugService, keybindingService, commandService, contextService, fileService);
super(id, label, debugService, keybindingService, commandService, contextService, fileService, textFileService);
}

protected getDefaultConfiguration(): any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { isMacintosh } from 'vs/base/common/platform';
import { ActionItem, BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor } from 'vs/workbench/browser/actionBarRegistry';
import { IEditorInputActionContext, IEditorInputAction, EditorInputActionContributor } from 'vs/workbench/browser/parts/editor/baseEditor';
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';
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';
import { RevertLocalChangesAction, AcceptLocalChangesAction, CONFLICT_RESOLUTION_SCHEME } from 'vs/workbench/parts/files/browser/saveErrorHandler';
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
Expand Down Expand Up @@ -213,7 +213,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalCopyPathAction,
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAction, SaveFileAction.ID, SaveFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_S }), 'Files: Save', category);
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);
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFilesAction, SaveFilesAction.ID, null /* only for programmatic trigger */), null);
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveIfDirtyFileAction, SaveIfDirtyFileAction.ID, null /* only for programmatic trigger */), null);
registry.registerWorkbenchAction(new SyncActionDescriptor(RevertFileAction, RevertFileAction.ID, RevertFileAction.LABEL), 'Files: Revert File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFileAction, GlobalNewFileAction.ID, GlobalNewFileAction.LABEL), 'Files: New File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFolderAction, GlobalNewFolderAction.ID, GlobalNewFolderAction.LABEL), 'Files: New Folder', category);
Expand Down
25 changes: 1 addition & 24 deletions src/vs/workbench/parts/files/browser/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
}

public abstract isSaveAs(): boolean;
protected abstract isForce(): boolean;

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

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

return TPromise.as(false);
}
}

export class SaveIfDirtyFileAction extends BaseSaveFileAction {

public static ID = 'workbench.action.files.saveIfDirty';
public static LABEL = nls.localize('saveIfDirty', "Save If Dirty");

public isSaveAs(): boolean {
return false;
}

protected isForce(): boolean {
return false;
}
}

export class SaveFileAction extends BaseSaveFileAction {

public static ID = 'workbench.action.files.save';
Expand All @@ -1453,10 +1438,6 @@ export class SaveFileAction extends BaseSaveFileAction {
public isSaveAs(): boolean {
return false;
}

protected isForce(): boolean {
return true;
}
}

export class SaveFileAsAction extends BaseSaveFileAction {
Expand All @@ -1467,10 +1448,6 @@ export class SaveFileAsAction extends BaseSaveFileAction {
public isSaveAs(): boolean {
return true;
}

protected isForce(): boolean {
return true;
}
}

export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
Expand Down

0 comments on commit 8076a19

Please sign in to comment.