提交 8076a19f 编写于 作者: I isidor

debug: save all untitled non dirty files before debug start

fixes #21681
上级 540a11e8
......@@ -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';
......@@ -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(() => {
......@@ -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();
}
......@@ -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 {
......
......@@ -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';
......@@ -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);
......
......@@ -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;
......@@ -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';
......@@ -1453,10 +1438,6 @@ export class SaveFileAction extends BaseSaveFileAction {
public isSaveAs(): boolean {
return false;
}
protected isForce(): boolean {
return true;
}
}
export class SaveFileAsAction extends BaseSaveFileAction {
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册