From 8076a19fdcab7e1fc1707952d652f0bb6c6db331 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 8 Mar 2017 11:34:22 +0100 Subject: [PATCH] debug: save all untitled non dirty files before debug start fixes #21681 --- .../parts/debug/browser/debugActions.ts | 11 +++++--- .../files/browser/fileActions.contribution.ts | 3 +-- .../parts/files/browser/fileActions.ts | 25 +------------------ 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index ad577cf792b..77e597371e7 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -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 { - 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 { diff --git a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts index cdf644eaeda..cd79eb2de58 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts @@ -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); diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 05af748681c..425b62f28d6 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -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 { -- GitLab