未验证 提交 e08c6d5d 编写于 作者: A Alex Ross 提交者: GitHub

Hang on to untitiled URI a little longer (#77221)

Fixes #77094
上级 d1483a48
......@@ -91,7 +91,8 @@ export class FileDialogService implements IFileDialogService {
}
private ensureFileSchema(schema: string): string[] {
return schema !== Schemas.file ? [schema, Schemas.file] : [schema];
// Don't allow untitled schema through.
return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
}
async pickFileFolderAndOpen(options: IPickAndOpenOptions): Promise<any> {
......@@ -207,6 +208,7 @@ export class FileDialogService implements IFileDialogService {
}
private toNativeSaveDialogOptions(options: ISaveDialogOptions): Electron.SaveDialogOptions {
options.defaultUri = options.defaultUri ? URI.file(options.defaultUri.path) : undefined;
return {
defaultPath: options.defaultUri && options.defaultUri.fsPath,
buttonLabel: options.saveLabel,
......@@ -286,12 +288,12 @@ export class FileDialogService implements IFileDialogService {
return remoteFileDialog.showSaveDialog(options);
}
private getSchemeFilterForWindow() {
private getSchemeFilterForWindow(): string {
return !this.environmentService.configuration.remoteAuthority ? Schemas.file : REMOTE_HOST_SCHEME;
}
private getFileSystemSchema(options: { availableFileSystems?: string[], defaultUri?: URI }): string {
return options.availableFileSystems && options.availableFileSystems[0] || options.defaultUri && options.defaultUri.scheme || this.getSchemeFilterForWindow();
return options.availableFileSystems && options.availableFileSystems[0] || this.getSchemeFilterForWindow();
}
}
......
......@@ -31,7 +31,6 @@ import { createTextBufferFactoryFromSnapshot, createTextBufferFactoryFromStream
import { IModelService } from 'vs/editor/common/services/modelService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { isEqualOrParent, isEqual, joinPath, dirname, extname, basename, toLocalResource } from 'vs/base/common/resources';
import { posix } from 'vs/base/common/path';
import { getConfirmMessage, IDialogService, IFileDialogService, ISaveDialogOptions, IConfirmation } from 'vs/platform/dialogs/common/dialogs';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
......@@ -538,7 +537,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
async confirmSave(resources?: URI[]): Promise<ConfirmResult> {
if (this.environmentService.isExtensionDevelopment) {
return ConfirmResult.DONT_SAVE; // no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests)
return ConfirmResult.DONT_SAVE; // no veto when we are in extension dev mode because we cannot assume we run interactive (e.g. tests)
}
const resourcesToConfirm = this.getDirty(resources);
......@@ -904,7 +903,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
return joinPath(lastActiveFolder, untitledFileName);
}
return schemeFilter === Schemas.file ? URI.file(untitledFileName) : URI.from({ scheme: schemeFilter, authority: remoteAuthority, path: posix.sep + untitledFileName });
return untitledResource.with({ path: untitledFileName });
}
async revert(resource: URI, options?: IRevertOptions): Promise<boolean> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册