mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
cut - ensure to use textfileservice#move() (for #72543)
This commit is contained in:
parent
d8f4d9b66b
commit
5c3b542295
|
@ -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")));
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue