Skip to content

Commit

Permalink
more testing on #10659
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 19, 2018
1 parent 54ff9a1 commit ea28332
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ suite('workspace-namespace', () => {
assert.ok(await vscode.workspace.applyEdit(we));
// todo@ben https://github.com/Microsoft/vscode/issues/52212
// let doc = await vscode.workspace.openTextDocument(newUri);
// assert.equal(doc.getText(), 'BarFooHello');
// assert.equal(doc.getText(), 'BarHelloFoo');
});

test('WorkspaceEdit: Problem recreating a renamed resource #42634', async function () {
Expand All @@ -605,9 +605,7 @@ suite('workspace-namespace', () => {

// todo@ben https://github.com/Microsoft/vscode/issues/52212
// let newDoc = await vscode.workspace.openTextDocument(newUri);
// assert.equal(newDoc.getText(), 'FooHello');

// todo@ben https://github.com/Microsoft/vscode/issues/52212
// assert.equal(newDoc.getText(), 'HelloFoo');
// let doc = await vscode.workspace.openTextDocument(docUri);
// assert.equal(doc.getText(), 'Bar');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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 @@ -91,15 +92,7 @@ class EditTask implements IDisposable {

apply(): void {
if (this._edits.length > 0) {

this._edits = this._edits.map((value, index) => ({ value, index })).sort((a, b) => {
let ret = Range.compareRangesUsingStarts(a.value.range, b.value.range);
if (ret === 0) {
ret = a.index - b.index;
}
return ret;
}).map(element => element.value);

this._edits = mergeSort(this._edits, (a, b) => Range.compareRangesUsingStarts(a.range, b.range));
this._initialSelections = this._getInitialSelections();
this._model.pushStackElement();
this._model.pushEditOperations(this._initialSelections, this._edits, (edits) => this._getEndCursorSelections(edits));
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,18 @@ suite('ExtHostTypes', function () {
assert.ok(isTextChange(fourth) && fourth[1].length === 1);
});

test('WorkspaceEdit - two edits for one resource', function () {
let edit = new types.WorkspaceEdit();
let uri = URI.parse('foo:bar');
edit.insert(uri, new types.Position(0, 0), 'Hello');
edit.insert(uri, new types.Position(0, 0), 'Foo');

assert.equal(edit.allEntries().length, 2);
let [first, second] = edit.allEntries();
assert.equal((first as [URI, types.TextEdit[]])[1][0].newText, 'Hello');
assert.equal((second as [URI, types.TextEdit[]])[1][0].newText, 'Foo');
});

test('DocumentLink', function () {
assert.throws(() => new types.DocumentLink(null, null));
assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null));
Expand Down

0 comments on commit ea28332

Please sign in to comment.