mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 12:08:36 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -3,23 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { compareFileNames, compareFileExtensions, setFileNameComparer } from 'vs/base/common/comparers';
|
||||
import { compareFileNames, compareFileExtensions } from 'vs/base/common/comparers';
|
||||
import * as assert from 'assert';
|
||||
import { IdleValue } from 'vs/base/common/async';
|
||||
|
||||
suite('Comparers', () => {
|
||||
|
||||
test('compareFileNames', () => {
|
||||
|
||||
// Setup Intl
|
||||
setFileNameComparer(new IdleValue(() => {
|
||||
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
||||
return {
|
||||
collator: collator,
|
||||
collatorIsNumeric: collator.resolvedOptions().numeric
|
||||
};
|
||||
}));
|
||||
|
||||
assert(compareFileNames(null, null) === 0, 'null should be equal');
|
||||
assert(compareFileNames(null, 'abc') < 0, 'null should be come before real values');
|
||||
assert(compareFileNames('', '') === 0, 'empty should be equal');
|
||||
@@ -35,15 +25,6 @@ suite('Comparers', () => {
|
||||
|
||||
test('compareFileExtensions', () => {
|
||||
|
||||
// Setup Intl
|
||||
setFileNameComparer(new IdleValue(() => {
|
||||
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
||||
return {
|
||||
collator: collator,
|
||||
collatorIsNumeric: collator.resolvedOptions().numeric
|
||||
};
|
||||
}));
|
||||
|
||||
assert(compareFileExtensions(null, null) === 0, 'null should be equal');
|
||||
assert(compareFileExtensions(null, '.abc') < 0, 'null should come before real files');
|
||||
assert(compareFileExtensions(null, 'abc') < 0, 'null should come before real files without extension');
|
||||
@@ -66,4 +47,4 @@ suite('Comparers', () => {
|
||||
assert(compareFileExtensions('file2.ext2', 'file1.ext10') < 0, 'extensions with numbers should be in numerical order, not alphabetical order');
|
||||
assert(compareFileExtensions('file.ext01', 'file.ext1') < 0, 'extensions with equal numbers should be in alphabetical order');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { createSHA1 } from 'vs/base/browser/hash';
|
||||
|
||||
suite('Hash', () => {
|
||||
test('computeSHA1Hash', async () => {
|
||||
assert.equal(await createSHA1(''), 'da39a3ee5e6b4b0d3255bfef95601890afd80709');
|
||||
assert.equal(await createSHA1('hello world'), '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed');
|
||||
assert.equal(await createSHA1('da39a3ee5e6b4b0d3255bfef95601890afd80709'), '10a34637ad661d98ba3344717656fcc76209c2f8');
|
||||
assert.equal(await createSHA1('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'), 'd6b0d82cea4269b51572b8fab43adcee9fc3cf9a');
|
||||
assert.equal(await createSHA1('öäü_?ß()<>ÖÄÜ'), 'b64beaeff9e317b0193c8e40a2431b210388eba9');
|
||||
});
|
||||
});
|
||||
@@ -5,8 +5,19 @@
|
||||
import * as assert from 'assert';
|
||||
import * as marked from 'vs/base/common/marked/marked';
|
||||
import { renderMarkdown, renderText, renderFormattedText } from 'vs/base/browser/htmlContentRenderer';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
|
||||
suite('HtmlContent', () => {
|
||||
const store = new DisposableStore();
|
||||
|
||||
setup(() => {
|
||||
store.clear();
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
store.clear();
|
||||
});
|
||||
|
||||
test('render simple element', () => {
|
||||
let result: HTMLElement = renderText('testing');
|
||||
|
||||
@@ -55,7 +66,7 @@ suite('HtmlContent', () => {
|
||||
assert.strictEqual(content, '0');
|
||||
callbackCalled = true;
|
||||
},
|
||||
disposeables: []
|
||||
disposeables: store
|
||||
}
|
||||
});
|
||||
assert.strictEqual(result.innerHTML, '<a href="#">action</a>');
|
||||
@@ -74,7 +85,7 @@ suite('HtmlContent', () => {
|
||||
assert.strictEqual(content, '0');
|
||||
callbackCalled = true;
|
||||
},
|
||||
disposeables: []
|
||||
disposeables: store
|
||||
}
|
||||
});
|
||||
assert.strictEqual(result.innerHTML, '<i><b><a href="#">action</a></b></i>');
|
||||
|
||||
@@ -59,8 +59,8 @@ suite('Gridview', function () {
|
||||
];
|
||||
|
||||
gridview.addView(views[0] as IView, 200, [0]);
|
||||
gridview.addView(views[1][0] as IView, 200, [1]);
|
||||
gridview.addView(views[1][1] as IView, 200, [1, 1]);
|
||||
gridview.addView((views[1] as TestView[])[0] as IView, 200, [1]);
|
||||
gridview.addView((views[1] as TestView[])[1] as IView, 200, [1, 1]);
|
||||
|
||||
assert.deepEqual(nodesToArrays(gridview.getViews()), views);
|
||||
|
||||
|
||||
@@ -326,4 +326,57 @@ suite('AsyncDataTree', function () {
|
||||
assert(!hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode(_('a')).collapsed);
|
||||
});
|
||||
|
||||
test('support default collapse state per element', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.style.width = '200px';
|
||||
container.style.height = '200px';
|
||||
|
||||
const delegate = new class implements IListVirtualDelegate<Element> {
|
||||
getHeight() { return 20; }
|
||||
getTemplateId(element: Element): string { return 'default'; }
|
||||
};
|
||||
|
||||
const renderer = new class implements ITreeRenderer<Element, void, HTMLElement> {
|
||||
readonly templateId = 'default';
|
||||
renderTemplate(container: HTMLElement): HTMLElement {
|
||||
return container;
|
||||
}
|
||||
renderElement(element: ITreeNode<Element, void>, index: number, templateData: HTMLElement): void {
|
||||
templateData.textContent = element.element.id;
|
||||
}
|
||||
disposeTemplate(templateData: HTMLElement): void {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
|
||||
const getChildrenCalls: string[] = [];
|
||||
const dataSource = new class implements IAsyncDataSource<Element, Element> {
|
||||
hasChildren(element: Element): boolean {
|
||||
return !!element.children && element.children.length > 0;
|
||||
}
|
||||
getChildren(element: Element): Promise<Element[]> {
|
||||
getChildrenCalls.push(element.id);
|
||||
return Promise.resolve(element.children || []);
|
||||
}
|
||||
};
|
||||
|
||||
const root: Element = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]
|
||||
}]
|
||||
};
|
||||
|
||||
const _: (id: string) => Element = find.bind(null, root.children);
|
||||
|
||||
const tree = new AsyncDataTree<Element, Element>(container, delegate, [renderer], dataSource, {
|
||||
collapseByDefault: el => el.id !== 'a'
|
||||
});
|
||||
tree.layout(200);
|
||||
|
||||
await tree.setInput(root);
|
||||
assert(!tree.getNode(_('a')).collapsed);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'a']);
|
||||
});
|
||||
});
|
||||
@@ -119,7 +119,7 @@ suite('Decorators', () => {
|
||||
assert.equal(foo.answer, 42);
|
||||
|
||||
try {
|
||||
foo['$memoize$answer'] = 1337;
|
||||
(foo as any)['$memoize$answer'] = 1337;
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert.equal(foo.answer, 42);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { Event, Emitter, EventBufferer, EventMultiplexer, AsyncEmitter, IWaitUntil, PauseableEmitter } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import * as Errors from 'vs/base/common/errors';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
@@ -73,6 +73,27 @@ suite('Event', function () {
|
||||
while (bucket.length) {
|
||||
bucket.pop()!.dispose();
|
||||
}
|
||||
doc.setText('boo');
|
||||
|
||||
// noop
|
||||
subscription.dispose();
|
||||
|
||||
doc.setText('boo');
|
||||
assert.equal(counter.count, 2);
|
||||
});
|
||||
|
||||
test('Emitter, store', function () {
|
||||
|
||||
let bucket = new DisposableStore();
|
||||
let doc = new Samples.Document3();
|
||||
let subscription = doc.onDidChange(counter.onEvent, counter, bucket);
|
||||
|
||||
doc.setText('far');
|
||||
doc.setText('boo');
|
||||
|
||||
// unhook listener
|
||||
bucket.clear();
|
||||
doc.setText('boo');
|
||||
|
||||
// noop
|
||||
subscription.dispose();
|
||||
|
||||
@@ -13,8 +13,8 @@ function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, hig
|
||||
}
|
||||
}
|
||||
|
||||
function filterNotOk(filter: IFilter, word: string, suggestion: string) {
|
||||
assert(!filter(word, suggestion));
|
||||
function filterNotOk(filter: IFilter, word: string, wordToMatchAgainst: string) {
|
||||
assert(!filter(word, wordToMatchAgainst), `${word} matched ${wordToMatchAgainst}`);
|
||||
}
|
||||
|
||||
suite('Filters', () => {
|
||||
@@ -185,23 +185,23 @@ suite('Filters', () => {
|
||||
assert(matchesWords('Debug Console', 'Open: Debug Console'));
|
||||
|
||||
filterOk(matchesWords, 'gp', 'Git: Pull', [{ start: 0, end: 1 }, { start: 5, end: 6 }]);
|
||||
filterOk(matchesWords, 'g p', 'Git: Pull', [{ start: 0, end: 1 }, { start: 4, end: 6 }]);
|
||||
filterOk(matchesWords, 'g p', 'Git: Pull', [{ start: 0, end: 1 }, { start: 3, end: 4 }, { start: 5, end: 6 }]);
|
||||
filterOk(matchesWords, 'gipu', 'Git: Pull', [{ start: 0, end: 2 }, { start: 5, end: 7 }]);
|
||||
|
||||
filterOk(matchesWords, 'gp', 'Category: Git: Pull', [{ start: 10, end: 11 }, { start: 15, end: 16 }]);
|
||||
filterOk(matchesWords, 'g p', 'Category: Git: Pull', [{ start: 10, end: 11 }, { start: 14, end: 16 }]);
|
||||
filterOk(matchesWords, 'g p', 'Category: Git: Pull', [{ start: 10, end: 11 }, { start: 13, end: 14 }, { start: 15, end: 16 }]);
|
||||
filterOk(matchesWords, 'gipu', 'Category: Git: Pull', [{ start: 10, end: 12 }, { start: 15, end: 17 }]);
|
||||
|
||||
filterNotOk(matchesWords, 'it', 'Git: Pull');
|
||||
filterNotOk(matchesWords, 'll', 'Git: Pull');
|
||||
|
||||
filterOk(matchesWords, 'git: プル', 'git: プル', [{ start: 0, end: 7 }]);
|
||||
filterOk(matchesWords, 'git プル', 'git: プル', [{ start: 0, end: 3 }, { start: 4, end: 7 }]);
|
||||
filterOk(matchesWords, 'git プル', 'git: プル', [{ start: 0, end: 4 }, { start: 5, end: 7 }]);
|
||||
|
||||
filterOk(matchesWords, 'öäk', 'Öhm: Älles Klar', [{ start: 0, end: 1 }, { start: 5, end: 6 }, { start: 11, end: 12 }]);
|
||||
|
||||
assert.ok(matchesWords('gipu', 'Category: Git: Pull', true) === null);
|
||||
assert.deepEqual(matchesWords('pu', 'Category: Git: Pull', true), [{ start: 15, end: 17 }]);
|
||||
// assert.ok(matchesWords('gipu', 'Category: Git: Pull', true) === null);
|
||||
// assert.deepEqual(matchesWords('pu', 'Category: Git: Pull', true), [{ start: 15, end: 17 }]);
|
||||
|
||||
filterOk(matchesWords, 'bar', 'foo-bar');
|
||||
filterOk(matchesWords, 'bar test', 'foo-bar test');
|
||||
@@ -212,7 +212,12 @@ suite('Filters', () => {
|
||||
filterNotOk(matchesWords, 'bar est', 'foo-bar test');
|
||||
filterNotOk(matchesWords, 'fo ar', 'foo-bar test');
|
||||
filterNotOk(matchesWords, 'for', 'foo-bar test');
|
||||
filterNotOk(matchesWords, 'foo bar', 'foo-bar');
|
||||
|
||||
filterOk(matchesWords, 'foo bar', 'foo-bar');
|
||||
filterOk(matchesWords, 'foo bar', '123 foo-bar 456');
|
||||
filterOk(matchesWords, 'foo+bar', 'foo-bar');
|
||||
filterOk(matchesWords, 'foo-bar', 'foo bar');
|
||||
filterOk(matchesWords, 'foo:bar', 'foo:bar');
|
||||
});
|
||||
|
||||
function assertMatches(pattern: string, word: string, decoratedWord: string | undefined, filter: FuzzyScorer, opts: { patternPos?: number, wordPos?: number, firstMatchCanBeWeak?: boolean } = {}) {
|
||||
|
||||
@@ -42,7 +42,8 @@ suite('Lifecycle', () => {
|
||||
assert(!disposable.isDisposed);
|
||||
assert(!disposable2.isDisposed);
|
||||
|
||||
dispose(disposable, disposable2);
|
||||
dispose(disposable);
|
||||
dispose(disposable2);
|
||||
|
||||
assert(disposable.isDisposed);
|
||||
assert(disposable2.isDisposed);
|
||||
|
||||
@@ -4,42 +4,43 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { guessMimeTypes, registerTextMime, suggestFilename } from 'vs/base/common/mime';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
suite('Mime', () => {
|
||||
|
||||
test('Dynamically Register Text Mime', () => {
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes(URI.file('foo.monaco'));
|
||||
assert.deepEqual(guess, ['application/unknown']);
|
||||
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco', mime: 'text/monaco' });
|
||||
guess = guessMimeTypes('foo.monaco');
|
||||
guess = guessMimeTypes(URI.file('foo.monaco'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('.monaco');
|
||||
guess = guessMimeTypes(URI.file('.monaco'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
registerTextMime({ id: 'codefile', filename: 'Codefile', mime: 'text/code' });
|
||||
guess = guessMimeTypes('Codefile');
|
||||
guess = guessMimeTypes(URI.file('Codefile'));
|
||||
assert.deepEqual(guess, ['text/code', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.Codefile');
|
||||
guess = guessMimeTypes(URI.file('foo.Codefile'));
|
||||
assert.deepEqual(guess, ['application/unknown']);
|
||||
|
||||
registerTextMime({ id: 'docker', filepattern: 'Docker*', mime: 'text/docker' });
|
||||
guess = guessMimeTypes('Docker-debug');
|
||||
guess = guessMimeTypes(URI.file('Docker-debug'));
|
||||
assert.deepEqual(guess, ['text/docker', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('docker-PROD');
|
||||
guess = guessMimeTypes(URI.file('docker-PROD'));
|
||||
assert.deepEqual(guess, ['text/docker', 'text/plain']);
|
||||
|
||||
registerTextMime({ id: 'niceregex', mime: 'text/nice-regex', firstline: /RegexesAreNice/ });
|
||||
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNice');
|
||||
guess = guessMimeTypes(URI.file('Randomfile.noregistration'), 'RegexesAreNice');
|
||||
assert.deepEqual(guess, ['text/nice-regex', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNotNice');
|
||||
guess = guessMimeTypes(URI.file('Randomfile.noregistration'), 'RegexesAreNotNice');
|
||||
assert.deepEqual(guess, ['application/unknown']);
|
||||
|
||||
guess = guessMimeTypes('Codefile', 'RegexesAreNice');
|
||||
guess = guessMimeTypes(URI.file('Codefile'), 'RegexesAreNice');
|
||||
assert.deepEqual(guess, ['text/code', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -47,20 +48,20 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco', mime: 'text/monaco' });
|
||||
registerTextMime({ id: 'foobar', mime: 'text/foobar', firstline: /foobar/ });
|
||||
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes(URI.file('foo.monaco'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.monaco', 'foobar');
|
||||
guess = guessMimeTypes(URI.file('foo.monaco'), 'foobar');
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
registerTextMime({ id: 'docker', filename: 'dockerfile', mime: 'text/winner' });
|
||||
registerTextMime({ id: 'docker', filepattern: 'dockerfile*', mime: 'text/looser' });
|
||||
guess = guessMimeTypes('dockerfile');
|
||||
guess = guessMimeTypes(URI.file('dockerfile'));
|
||||
assert.deepEqual(guess, ['text/winner', 'text/plain']);
|
||||
|
||||
registerTextMime({ id: 'azure-looser', mime: 'text/azure-looser', firstline: /azure/ });
|
||||
registerTextMime({ id: 'azure-winner', mime: 'text/azure-winner', firstline: /azure/ });
|
||||
guess = guessMimeTypes('azure', 'azure');
|
||||
guess = guessMimeTypes(URI.file('azure'), 'azure');
|
||||
assert.deepEqual(guess, ['text/azure-winner', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -68,16 +69,16 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco2', extension: '.monaco2', mime: 'text/monaco2' });
|
||||
registerTextMime({ id: 'monaco2', filename: 'specific.monaco2', mime: 'text/specific-monaco2' });
|
||||
|
||||
assert.deepEqual(guessMimeTypes('specific.monaco2'), ['text/specific-monaco2', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes('foo.monaco2'), ['text/monaco2', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes(URI.file('specific.monaco2')), ['text/specific-monaco2', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes(URI.file('foo.monaco2')), ['text/monaco2', 'text/plain']);
|
||||
});
|
||||
|
||||
test('Specificity priority 2', () => {
|
||||
registerTextMime({ id: 'monaco3', filename: 'specific.monaco3', mime: 'text/specific-monaco3' });
|
||||
registerTextMime({ id: 'monaco3', extension: '.monaco3', mime: 'text/monaco3' });
|
||||
|
||||
assert.deepEqual(guessMimeTypes('specific.monaco3'), ['text/specific-monaco3', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes('foo.monaco3'), ['text/monaco3', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes(URI.file('specific.monaco3')), ['text/specific-monaco3', 'text/plain']);
|
||||
assert.deepEqual(guessMimeTypes(URI.file('foo.monaco3')), ['text/monaco3', 'text/plain']);
|
||||
});
|
||||
|
||||
test('Mimes Priority - Longest Extension wins', () => {
|
||||
@@ -85,13 +86,13 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml', mime: 'text/monaco-xml' });
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml.build', mime: 'text/monaco-xml-build' });
|
||||
|
||||
let guess = guessMimeTypes('foo.monaco');
|
||||
let guess = guessMimeTypes(URI.file('foo.monaco'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.monaco.xml');
|
||||
guess = guessMimeTypes(URI.file('foo.monaco.xml'));
|
||||
assert.deepEqual(guess, ['text/monaco-xml', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('foo.monaco.xml.build');
|
||||
guess = guessMimeTypes(URI.file('foo.monaco.xml.build'));
|
||||
assert.deepEqual(guess, ['text/monaco-xml-build', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -99,7 +100,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xnl', mime: 'text/monaco', userConfigured: true });
|
||||
registerTextMime({ id: 'monaco', extension: '.monaco.xml', mime: 'text/monaco-xml' });
|
||||
|
||||
let guess = guessMimeTypes('foo.monaco.xnl');
|
||||
let guess = guessMimeTypes(URI.file('foo.monaco.xnl'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -107,7 +108,7 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', filepattern: '**/dot.monaco.xml', mime: 'text/monaco' });
|
||||
registerTextMime({ id: 'other', filepattern: '*ot.other.xml', mime: 'text/other' });
|
||||
|
||||
let guess = guessMimeTypes('/some/path/dot.monaco.xml');
|
||||
let guess = guessMimeTypes(URI.file('/some/path/dot.monaco.xml'));
|
||||
assert.deepEqual(guess, ['text/monaco', 'text/plain']);
|
||||
});
|
||||
|
||||
@@ -115,10 +116,16 @@ suite('Mime', () => {
|
||||
registerTextMime({ id: 'monaco', filepattern: '**/dot.monaco.xml', mime: 'text/monaco' });
|
||||
registerTextMime({ id: 'other', filepattern: '**/dot.monaco.xml', mime: 'text/other' });
|
||||
|
||||
let guess = guessMimeTypes('/some/path/dot.monaco.xml');
|
||||
let guess = guessMimeTypes(URI.file('/some/path/dot.monaco.xml'));
|
||||
assert.deepEqual(guess, ['text/other', 'text/plain']);
|
||||
});
|
||||
|
||||
test('Data URIs', () => {
|
||||
registerTextMime({ id: 'data', extension: '.data', mime: 'text/data' });
|
||||
|
||||
assert.deepEqual(guessMimeTypes(URI.parse(`data:;label:something.data;description:data,`)), ['text/data', 'text/plain']);
|
||||
});
|
||||
|
||||
test('Filename Suggestion - Suggest prefix only when there are no relevant extensions', () => {
|
||||
const id = 'plumbus0';
|
||||
const mime = `text/${id}`;
|
||||
|
||||
@@ -237,8 +237,8 @@ suite('Resources', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function assertRelativePath(u1: URI, u2: URI, expectedPath: string | undefined, ignoreJoin?: boolean) {
|
||||
assert.equal(relativePath(u1, u2), expectedPath, `from ${u1.toString()} to ${u2.toString()}`);
|
||||
function assertRelativePath(u1: URI, u2: URI, expectedPath: string | undefined, ignoreJoin?: boolean, ignoreCase?: boolean) {
|
||||
assert.equal(relativePath(u1, u2, ignoreCase), expectedPath, `from ${u1.toString()} to ${u2.toString()}`);
|
||||
if (expectedPath !== undefined && !ignoreJoin) {
|
||||
assertEqualURI(removeTrailingPathSeparator(joinPath(u1, expectedPath)), removeTrailingPathSeparator(u2), 'joinPath on relativePath should be equal');
|
||||
}
|
||||
@@ -263,6 +263,11 @@ suite('Resources', () => {
|
||||
assertRelativePath(URI.parse('foo://a2/b'), URI.parse('foo://a/b'), undefined);
|
||||
assertRelativePath(URI.parse('goo://a/b'), URI.parse('foo://a/b'), undefined);
|
||||
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://A/FOO/bar/goo'), 'bar/goo', false, true);
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://A/FOO/BAR/GOO'), 'BAR/GOO', false, true);
|
||||
assertRelativePath(URI.parse('foo://a/foo/xoo'), URI.parse('foo://A/FOO/BAR/GOO'), '../BAR/GOO', false, true);
|
||||
assertRelativePath(URI.parse('foo:///c:/a/foo'), URI.parse('foo:///C:/a/foo/xoo/'), 'xoo', false, true);
|
||||
|
||||
if (isWindows) {
|
||||
assertRelativePath(URI.file('c:\\foo\\bar'), URI.file('c:\\foo\\bar'), '');
|
||||
assertRelativePath(URI.file('c:\\foo\\bar\\huu'), URI.file('c:\\foo\\bar'), '..');
|
||||
|
||||
@@ -426,6 +426,19 @@ suite('URI', () => {
|
||||
assert.equal(uri.toString(true), input);
|
||||
});
|
||||
|
||||
test('Unable to open \'%A0.txt\': URI malformed #76506', function () {
|
||||
|
||||
let uri = URI.file('/foo/%A0.txt');
|
||||
let uri2 = URI.parse(uri.toString());
|
||||
assert.equal(uri.scheme, uri2.scheme);
|
||||
assert.equal(uri.path, uri2.path);
|
||||
|
||||
uri = URI.file('/foo/%2e.txt');
|
||||
uri2 = URI.parse(uri.toString());
|
||||
assert.equal(uri.scheme, uri2.scheme);
|
||||
assert.equal(uri.path, uri2.path);
|
||||
});
|
||||
|
||||
test('URI - (de)serialize', function () {
|
||||
|
||||
const values = [
|
||||
|
||||
@@ -364,4 +364,42 @@ suite('Buffer', () => {
|
||||
assert.equal(ended, false);
|
||||
assert.equal(errors.length, 0);
|
||||
});
|
||||
|
||||
test('Performance issue with VSBuffer#slice #76076', function () {
|
||||
// Buffer#slice creates a view
|
||||
{
|
||||
const buff = Buffer.from([10, 20, 30, 40]);
|
||||
const b2 = buff.slice(1, 3);
|
||||
assert.equal(buff[1], 20);
|
||||
assert.equal(b2[0], 20);
|
||||
|
||||
buff[1] = 17; // modify buff AND b2
|
||||
assert.equal(buff[1], 17);
|
||||
assert.equal(b2[0], 17);
|
||||
}
|
||||
|
||||
// TypedArray#slice creates a copy
|
||||
{
|
||||
const unit = new Uint8Array([10, 20, 30, 40]);
|
||||
const u2 = unit.slice(1, 3);
|
||||
assert.equal(unit[1], 20);
|
||||
assert.equal(u2[0], 20);
|
||||
|
||||
unit[1] = 17; // modify unit, NOT b2
|
||||
assert.equal(unit[1], 17);
|
||||
assert.equal(u2[0], 20);
|
||||
}
|
||||
|
||||
// TypedArray#subarray creates a view
|
||||
{
|
||||
const unit = new Uint8Array([10, 20, 30, 40]);
|
||||
const u2 = unit.subarray(1, 3);
|
||||
assert.equal(unit[1], 20);
|
||||
assert.equal(u2[0], 20);
|
||||
|
||||
unit[1] = 17; // modify unit AND b2
|
||||
assert.equal(unit[1], 17);
|
||||
assert.equal(u2[0], 17);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as getmac from 'getmac';
|
||||
import { getMachineId } from 'vs/base/node/id';
|
||||
import { getMac } from 'vs/base/node/macAddress';
|
||||
|
||||
suite('ID', () => {
|
||||
|
||||
@@ -16,9 +16,7 @@ suite('ID', () => {
|
||||
});
|
||||
|
||||
test('getMac', () => {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
getmac.getMac((err, macAddress) => err ? reject(err) : resolve(macAddress));
|
||||
}).then(macAddress => {
|
||||
return getMac().then(macAddress => {
|
||||
assert.ok(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(macAddress), `Expected a MAC address, got: ${macAddress}`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { isWindows, isLinux } from 'vs/base/common/platform';
|
||||
import { canNormalize } from 'vs/base/common/normalization';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { join } from 'path';
|
||||
|
||||
const chunkSize = 64 * 1024;
|
||||
const readError = 'Error while reading';
|
||||
@@ -386,6 +387,31 @@ suite('PFS', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('readdirWithFileTypes', async () => {
|
||||
if (canNormalize && typeof process.versions['electron'] !== 'undefined' /* needs electron */) {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const testDir = join(parentDir, 'pfs', id);
|
||||
|
||||
const newDir = path.join(testDir, 'öäü');
|
||||
await pfs.mkdirp(newDir, 493);
|
||||
|
||||
await pfs.writeFile(join(testDir, 'somefile.txt'), 'contents');
|
||||
|
||||
assert.ok(fs.existsSync(newDir));
|
||||
|
||||
const children = await pfs.readdirWithFileTypes(testDir);
|
||||
|
||||
assert.equal(children.some(n => n.name === 'öäü'), true); // Mac always converts to NFD, so
|
||||
assert.equal(children.some(n => n.isDirectory()), true);
|
||||
|
||||
assert.equal(children.some(n => n.name === 'somefile.txt'), true);
|
||||
assert.equal(children.some(n => n.isFile()), true);
|
||||
|
||||
await pfs.rimraf(parentDir);
|
||||
}
|
||||
});
|
||||
|
||||
test('writeFile (string)', async () => {
|
||||
const smallData = 'Hello World';
|
||||
const bigData = (new Array(100 * 1024)).join('Large String\n');
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,40 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------
|
||||
The base color for this template is #5c87b2. If you'd like
|
||||
to use a different color start by replacing all instances of
|
||||
#5c87b2 with your new color.
|
||||
----------------------------------------------------------*/
|
||||
body
|
||||
{
|
||||
background-color: #5c87b2;
|
||||
font-size: .75em;
|
||||
font-family: Segoe UI, Verdana, Helvetica, Sans-Serif;
|
||||
margin: 8px;
|
||||
padding: 0;
|
||||
color: #696969;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6
|
||||
{
|
||||
color: #000;
|
||||
font-size: 40px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
textarea
|
||||
{
|
||||
font-family: Consolas
|
||||
}
|
||||
|
||||
#results
|
||||
{
|
||||
margin-top: 2em;
|
||||
margin-left: 2em;
|
||||
color: black;
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
import * as stream from 'vs/base/node/stream';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
suite('Stream', () => {
|
||||
test('readToMatchingString - ANSI', async () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/file.css');
|
||||
|
||||
const result = await stream.readToMatchingString(file, '\n', 10, 100);
|
||||
|
||||
// \r may be present on Windows
|
||||
assert.equal(result!.replace('\r', ''), '/*---------------------------------------------------------------------------------------------');
|
||||
});
|
||||
|
||||
test('readToMatchingString - empty', async () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/empty.txt');
|
||||
|
||||
const result = await stream.readToMatchingString(file, '\n', 10, 100);
|
||||
assert.equal(result, null);
|
||||
});
|
||||
});
|
||||
@@ -16,8 +16,8 @@ export interface ITestFileResult {
|
||||
export function testFile(folder: string, file: string): Promise<ITestFileResult> {
|
||||
const id = generateUuid();
|
||||
const parentDir = join(tmpdir(), 'vsctests', id);
|
||||
const newDir = join(parentDir, 'config', id);
|
||||
const testFile = join(newDir, 'config.json');
|
||||
const newDir = join(parentDir, folder, id);
|
||||
const testFile = join(newDir, file);
|
||||
|
||||
return mkdirp(newDir, 493).then(() => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user