mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 16:58:55 -05:00
fix #52447
This commit is contained in:
@@ -689,8 +689,7 @@ suite('workspace-namespace', () => {
|
||||
we = new vscode.WorkspaceEdit();
|
||||
we.createFile(docUri, { overwrite: true });
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
// todo@ben
|
||||
// assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), '');
|
||||
assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), '');
|
||||
});
|
||||
|
||||
test('WorkspaceEdit: create & ignoreIfExists', async function () {
|
||||
|
||||
@@ -343,7 +343,7 @@ export class BulkEdit {
|
||||
} else if (edit.newUri && !edit.oldUri) {
|
||||
let ignoreIfExists = edit.options && edit.options.ignoreIfExists;
|
||||
if (!ignoreIfExists || !await this._fileService.existsFile(edit.newUri)) {
|
||||
await this._fileService.createFile(edit.newUri, undefined, { overwrite });
|
||||
await this._textFileService.create(edit.newUri, undefined, { overwrite });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,6 +692,20 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
});
|
||||
}
|
||||
|
||||
create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise<void> {
|
||||
return this.fileService.createFile(resource, contents, options).then(() => {
|
||||
|
||||
// If we had an existing model for the given resource, load
|
||||
// it again to make sure it is up to date with the contents
|
||||
// we just wrote into the underlying resource.
|
||||
if (!!this.models.get(resource)) {
|
||||
return this.models.loadOrCreate(resource, { reload: { async: false } }).then(() => void 0);
|
||||
}
|
||||
|
||||
return void 0;
|
||||
});
|
||||
}
|
||||
|
||||
delete(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): TPromise<void> {
|
||||
const dirtyFiles = this.getDirty().filter(dirty => isEqualOrParent(dirty, resource, !platform.isLinux /* ignorecase */));
|
||||
|
||||
|
||||
@@ -328,6 +328,12 @@ export interface ITextFileService extends IDisposable {
|
||||
*/
|
||||
revertAll(resources?: URI[], options?: IRevertOptions): TPromise<ITextFileOperationResult>;
|
||||
|
||||
/**
|
||||
* Create a file. If the file exists it will be overwritten with the contents if
|
||||
* the options enable to overwrite.
|
||||
*/
|
||||
create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise<void>;
|
||||
|
||||
/**
|
||||
* Delete a file. If the file is dirty, it will get reverted and then deleted from disk.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user