Add saved files to recently opened (#20470)

This commit is contained in:
Charles Gagnon
2022-08-29 09:04:59 -07:00
committed by GitHub
parent 96b7335cdd
commit a78a158acd
5 changed files with 20 additions and 40 deletions

View File

@@ -193,12 +193,8 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
}
}
private addFileToRecentlyOpened(uri: URI): void {
// add the picked file into the list of recently opened
// only if it is outside the currently opened workspace
if (!this.contextService.isInsideWorkspace(uri)) {
this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri) }]);
}
protected addFileToRecentlyOpened(uri: URI): void {
this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri) }]);
}
protected async pickFolderAndOpenSimplified(schema: string, options: IPickAndOpenOptions): Promise<void> {
@@ -228,7 +224,13 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
}
options.title = nls.localize('saveFileAs.title', 'Save As');
return this.saveRemoteResource(options);
const uri = await this.saveRemoteResource(options);
if (uri) {
this.addFileToRecentlyOpened(uri);
}
return uri;
}
protected async showSaveDialogSimplified(schema: string, options: ISaveDialogOptions): Promise<URI | undefined> {

View File

@@ -131,7 +131,11 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
} else {
const result = await this.nativeHostService.showSaveDialog(this.toNativeSaveDialogOptions(options));
if (result && !result.canceled && result.filePath) {
return URI.file(result.filePath);
const uri = URI.file(result.filePath);
this.addFileToRecentlyOpened(uri);
return uri;
}
}
return undefined; // {{SQL CARBON EDIT}} strict-null-check