Skip to content

Commit

Permalink
override -> overwrite, #10659
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 20, 2018
1 parent 738fa55 commit f0ec28b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ suite('workspace-namespace', () => {
assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), 'before');

we = new vscode.WorkspaceEdit();
we.createFile(docUri, { override: true });
we.createFile(docUri, { overwrite: true });
assert.ok(await vscode.workspace.applyEdit(we));
// todo@ben
// assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), '');
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ export function isResourceTextEdit(thing: any): thing is ResourceTextEdit {
export interface ResourceFileEdit {
oldUri: URI;
newUri: URI;
options: { override: boolean };
options: { overwrite: boolean };
}

export interface ResourceTextEdit {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5101,7 +5101,7 @@ declare namespace monaco.languages {
oldUri: Uri;
newUri: Uri;
options: {
override: boolean;
overwrite: boolean;
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ declare module 'vscode' {
//#region joh: https://github.com/Microsoft/vscode/issues/10659

export interface WorkspaceEdit {
createFile(uri: Uri, options?: { override?: boolean }): void;
createFile(uri: Uri, options?: { overwrite?: boolean }): void;
deleteFile(uri: Uri): void;
renameFile(oldUri: Uri, newUri: Uri, options?: { override?: boolean }): void;
renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean }): void;

// replaceText(uri: Uri, range: Range, newText: string): void;
// insertText(uri: Uri, position: Position, newText: string): void;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export interface WorkspaceSymbolsDto extends IdObject {
export interface ResourceFileEditDto {
oldUri: UriComponents;
newUri: UriComponents;
options: { override?: boolean };
options: { overwrite?: boolean };
}

export interface ResourceTextEditDto {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export interface IFileOperation {
_type: 1;
from: URI;
to: URI;
options?: { override?: boolean };
options?: { overwrite?: boolean };
}

export interface IFileTextEdit {
Expand All @@ -512,11 +512,11 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {

private _edits = new Array<IFileOperation | IFileTextEdit>();

renameFile(from: vscode.Uri, to: vscode.Uri, options?: { override?: boolean }): void {
renameFile(from: vscode.Uri, to: vscode.Uri, options?: { overwrite?: boolean }): void {
this._edits.push({ _type: 1, from, to, options });
}

createFile(uri: vscode.Uri, options?: { override?: boolean }): void {
createFile(uri: vscode.Uri, options?: { overwrite?: boolean }): void {
this.renameFile(undefined, uri, options);
}

Expand Down Expand Up @@ -593,8 +593,8 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
return values(textEdits);
}

allEntries(): ([URI, TextEdit[]] | [URI, URI, { override?: boolean }])[] {
let res: ([URI, TextEdit[]] | [URI, URI, { override?: boolean }])[] = [];
allEntries(): ([URI, TextEdit[]] | [URI, URI, { overwrite?: boolean }])[] {
let res: ([URI, TextEdit[]] | [URI, URI, { overwrite?: boolean }])[] = [];
for (let edit of this._edits) {
if (edit._type === 1) {
res.push([edit.from, edit.to, edit.options]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'use strict';


import { mergeSort } from 'vs/base/common/arrays';
import { getPathLabel } from 'vs/base/common/labels';
import { dispose, IDisposable, IReference } from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
Expand All @@ -27,7 +28,6 @@ import { emptyProgressRunner, IProgress, IProgressRunner } from 'vs/platform/pro
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { mergeSort } from 'vs/base/common/arrays';

abstract class Recording {

Expand Down Expand Up @@ -335,12 +335,13 @@ export class BulkEdit {
for (const edit of edits) {
progress.report(undefined);

let overwrite = edit.options && edit.options.overwrite;
if (edit.newUri && edit.oldUri) {
await this._textFileService.move(edit.oldUri, edit.newUri, edit.options && edit.options.override);
await this._textFileService.move(edit.oldUri, edit.newUri, overwrite);
} else if (!edit.newUri && edit.oldUri) {
await this._textFileService.delete(edit.oldUri, true);
} else if (edit.newUri && !edit.oldUri) {
await this._fileService.createFile(edit.newUri, undefined, { overwrite: edit.options && edit.options.override });
await this._fileService.createFile(edit.newUri, undefined, { overwrite });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ suite('ExtHostTypes', function () {
const all = edit.allEntries();
assert.equal(all.length, 4);

function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { override?: boolean }]): thing is [URI, URI, { override?: boolean }] {
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] {
const [f, s] = thing;
return URI.isUri(f) && URI.isUri(s);
}

function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI, { override?: boolean }]): thing is [URI, types.TextEdit[]] {
function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, types.TextEdit[]] {
const [f, s] = thing;
return URI.isUri(f) && Array.isArray(s);
}
Expand Down

0 comments on commit f0ec28b

Please sign in to comment.