提交 091c626b 编写于 作者: B Benjamin Pasero

fix #58799

上级 2f5f3bcd
......@@ -99,7 +99,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent>;
abstract promptForPath(defaultPath: string): TPromise<string>;
abstract promptForPath(resource: URI, defaultPath: string): TPromise<string>;
abstract confirmSave(resources?: URI[]): TPromise<ConfirmResult>;
......@@ -433,7 +433,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
// Otherwise ask user
else {
const targetPath = await this.promptForPath(this.suggestFileName(untitled));
const targetPath = await this.promptForPath(untitled, this.suggestFileName(untitled));
if (!targetPath) {
return TPromise.as({
results: [...fileResources, ...untitledResources].map(r => {
......@@ -534,7 +534,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
dialogPath = this.suggestFileName(resource);
}
targetPromise = this.promptForPath(dialogPath).then(pathRaw => {
targetPromise = this.promptForPath(resource, dialogPath).then(pathRaw => {
if (pathRaw) {
return URI.file(pathRaw);
}
......
......@@ -30,6 +30,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IModelService } from 'vs/editor/common/services/modelService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { getConfirmMessage, IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
export class TextFileService extends AbstractTextFileService {
......@@ -49,7 +50,8 @@ export class TextFileService extends AbstractTextFileService {
@IWindowsService windowsService: IWindowsService,
@IHistoryService historyService: IHistoryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IDialogService private dialogService: IDialogService
@IDialogService private dialogService: IDialogService,
@IEditorService private editorService: IEditorService
) {
super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, notificationService, environmentService, backupFileService, windowsService, historyService, contextKeyService, modelService);
}
......@@ -102,8 +104,12 @@ export class TextFileService extends AbstractTextFileService {
});
}
promptForPath(defaultPath: string): TPromise<string> {
return this.windowService.showSaveDialog(this.getSaveDialogOptions(defaultPath));
promptForPath(resource: URI, defaultPath: string): TPromise<string> {
// Help user to find a name for the file by opening it first
return this.editorService.openEditor({ resource, options: { revealIfOpened: true, preserveFocus: true, } }).then(() => {
return this.windowService.showSaveDialog(this.getSaveDialogOptions(defaultPath));
});
}
private getSaveDialogOptions(defaultPath: string): Electron.SaveDialogOptions {
......
......@@ -222,7 +222,7 @@ export class TestTextFileService extends TextFileService {
});
}
public promptForPath(defaultPath: string): TPromise<string> {
public promptForPath(resource: URI, defaultPath: string): TPromise<string> {
return TPromise.wrap(this.promptPath);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册