cut - ensure to use textfileservice#move() (for #72543)

This commit is contained in:
Benjamin Pasero 2019-05-27 10:52:32 +02:00
parent d8f4d9b66b
commit 5c3b542295
4 changed files with 9 additions and 6 deletions

View file

@ -1056,6 +1056,7 @@ export const pasteFileHandler = (accessor: ServicesAccessor) => {
const clipboardService = accessor.get(IClipboardService);
const explorerService = accessor.get(IExplorerService);
const fileService = accessor.get(IFileService);
const textFileService = accessor.get(ITextFileService);
const notificationService = accessor.get(INotificationService);
const editorService = accessor.get(IEditorService);
@ -1083,8 +1084,8 @@ export const pasteFileHandler = (accessor: ServicesAccessor) => {
const targetFile = findValidPasteFileTarget(target, { resource: fileToPaste, isDirectory: fileToPasteStat.isDirectory, allowOverwirte: pasteShouldMove });
// Copy File
return pasteShouldMove ? fileService.move(fileToPaste, targetFile) : fileService.copy(fileToPaste, targetFile);
// Move/Copy File
return pasteShouldMove ? textFileService.move(fileToPaste, targetFile) : fileService.copy(fileToPaste, targetFile);
}, error => {
onError(notificationService, new Error(nls.localize('fileDeleted', "File to paste was deleted or moved meanwhile")));
});

View file

@ -443,7 +443,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
return this.fileService.del(resource, options);
}
async move(source: URI, target: URI, overwrite?: boolean): Promise<void> {
async move(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
const waitForPromises: Promise<unknown>[] = [];
// Event
@ -498,10 +498,12 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
// Rename to target
try {
await this.fileService.move(source, target, overwrite);
const stat = await this.fileService.move(source, target, overwrite);
// Load models that were dirty before
await Promise.all(dirtyTargetModelUris.map(dirtyTargetModel => this.models.loadOrCreate(dirtyTargetModel)));
return stat;
} catch (error) {
// In case of an error, discard any dirty target backups that were made

View file

@ -125,7 +125,7 @@ export interface ITextFileService extends IDisposable {
/**
* Move a file. If the file is dirty, its contents will be preserved and restored.
*/
move(source: URI, target: URI, overwrite?: boolean): Promise<void>;
move(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata>;
/**
* Brings up the confirm dialog to either save, don't save or cancel.

View file

@ -62,7 +62,7 @@ suite('MainThreadEditors', () => {
}
move(source: URI, target: URI) {
movedResources.set(source, target);
return Promise.resolve(undefined);
return Promise.resolve(Object.create(null));
}
models = <any>{
onModelSaved: Event.None,