mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Merge branch 'master' into ben/stacks
This commit is contained in:
@@ -40,23 +40,6 @@ suite('commands namespace tests', () => {
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('api-command: workbench.html.preview', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('speciale', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return `content of URI <b>${uri.toString()}</b>`;
|
||||
}
|
||||
});
|
||||
|
||||
let virtualDocumentUri = Uri.parse('speciale://authority/path');
|
||||
|
||||
return commands.executeCommand('vscode.previewHtml', virtualDocumentUri).then(success => {
|
||||
assert.ok(success);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('editorCommand with extra args', function () {
|
||||
|
||||
let args: IArguments;
|
||||
@@ -77,4 +60,46 @@ suite('commands namespace tests', () => {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('api-command: vscode.previewHtm', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('speciale', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return `content of URI <b>${uri.toString()}</b>`;
|
||||
}
|
||||
});
|
||||
|
||||
let virtualDocumentUri = Uri.parse('speciale://authority/path');
|
||||
|
||||
return commands.executeCommand('vscode.previewHtml', virtualDocumentUri).then(success => {
|
||||
assert.ok(success);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('api-command: vscode.diff', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('sc', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return `content of URI <b>${uri.toString()}</b>#${Math.random()}`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let a = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'DIFF').then(value => {
|
||||
assert.ok(value === void 0);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
let b = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b')).then(value => {
|
||||
assert.ok(value === void 0);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
let c = commands.executeCommand('vscode.diff').then(() => assert.ok(false), () => assert.ok(true));
|
||||
let d = commands.executeCommand('vscode.diff', 1, 2, 3).then(() => assert.ok(false), () => assert.ok(true));
|
||||
|
||||
return Promise.all([a, b, c]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import {workspace, window, Position} from 'vscode';
|
||||
import {workspace, window, Position, Range} from 'vscode';
|
||||
import {createRandomFile, deleteFile, cleanUp} from './utils';
|
||||
import {join} from 'path';
|
||||
|
||||
@@ -38,4 +38,27 @@ suite("editor tests", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #6281: Edits fail to validate ranges correctly before applying', () => {
|
||||
return createRandomFile('Hello world!').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
return window.showTextDocument(doc).then((editor) => {
|
||||
return editor.edit((builder) => {
|
||||
builder.replace(new Range(0, 0, Number.MAX_VALUE, Number.MAX_VALUE), 'new');
|
||||
}).then(applied => {
|
||||
assert.ok(applied);
|
||||
assert.equal(doc.getText(), 'new');
|
||||
assert.ok(doc.isDirty);
|
||||
|
||||
return doc.save().then(saved => {
|
||||
assert.ok(saved);
|
||||
assert.ok(!doc.isDirty);
|
||||
|
||||
return deleteFile(file);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -79,6 +79,55 @@ suite('languages namespace tests', () => {
|
||||
collection.dispose();
|
||||
});
|
||||
|
||||
test('diagnostics collection, set with dupliclated tuples', function () {
|
||||
let collection = languages.createDiagnosticCollection('test');
|
||||
let uri = Uri.parse('sc:hightower');
|
||||
collection.set([
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
|
||||
[Uri.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]],
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-2')]],
|
||||
]);
|
||||
|
||||
let array = collection.get(uri);
|
||||
assert.equal(array.length, 2);
|
||||
let [first, second] = array;
|
||||
assert.equal(first.message, 'message-1');
|
||||
assert.equal(second.message, 'message-2');
|
||||
|
||||
// clear
|
||||
collection.delete(uri);
|
||||
assert.ok(!collection.has(uri));
|
||||
|
||||
// bad tuple clears 1/2
|
||||
collection.set([
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
|
||||
[Uri.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]],
|
||||
[uri, undefined]
|
||||
]);
|
||||
assert.ok(!collection.has(uri));
|
||||
|
||||
// clear
|
||||
collection.delete(uri);
|
||||
assert.ok(!collection.has(uri));
|
||||
|
||||
// bad tuple clears 2/2
|
||||
collection.set([
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
|
||||
[Uri.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]],
|
||||
[uri, undefined],
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-2')]],
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-3')]],
|
||||
]);
|
||||
|
||||
array = collection.get(uri);
|
||||
assert.equal(array.length, 2);
|
||||
[first, second] = array;
|
||||
assert.equal(first.message, 'message-2');
|
||||
assert.equal(second.message, 'message-3');
|
||||
|
||||
collection.dispose();
|
||||
});
|
||||
|
||||
test('diagnostics & CodeActionProvider', function (done) {
|
||||
|
||||
class D2 extends Diagnostic {
|
||||
|
||||
@@ -294,6 +294,23 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, empty doc', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
const uri = Uri.parse('foo:doc/empty');
|
||||
|
||||
return workspace.openTextDocument(uri).then(doc => {
|
||||
assert.equal(doc.getText(), '');
|
||||
assert.equal(doc.uri.toString(), uri.toString());
|
||||
registration.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, change event', function () {
|
||||
|
||||
let callCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user