mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
fix two issues with notebookType and document selectors, (1) make sure that notebookType: *
matches only when a notebook is around, (2) include notebookType
-property when converting from extHost type to renderer type, fyi @dbaeumer
This commit is contained in:
parent
89d1004371
commit
5931aa8ed6
|
@ -87,7 +87,7 @@ export function score(selector: LanguageSelector | undefined, candidateUri: URI,
|
|||
if (notebookType) {
|
||||
if (notebookType === candidateNotebookType) {
|
||||
ret = 10;
|
||||
} else if (notebookType === '*') {
|
||||
} else if (notebookType === '*' && candidateNotebookType !== undefined) {
|
||||
ret = Math.max(ret, 5);
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -131,4 +131,23 @@ suite('LanguageSelector', function () {
|
|||
let value = score(selector, URI.file('/home/user/Desktop/test.json'), 'json', true, undefined);
|
||||
assert.strictEqual(value, 10);
|
||||
});
|
||||
|
||||
test('NotebookType without notebook', function () {
|
||||
let obj = {
|
||||
uri: URI.parse('file:///my/file.bat'),
|
||||
langId: 'bat',
|
||||
};
|
||||
|
||||
let value = score({
|
||||
language: 'bat',
|
||||
notebookType: 'xxx'
|
||||
}, obj.uri, obj.langId, true, undefined);
|
||||
assert.strictEqual(value, 0);
|
||||
|
||||
value = score({
|
||||
language: 'bat',
|
||||
notebookType: '*'
|
||||
}, obj.uri, obj.langId, true, undefined);
|
||||
assert.strictEqual(value, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1491,7 +1491,8 @@ export namespace LanguageSelector {
|
|||
language: filter.language,
|
||||
scheme: filter.scheme,
|
||||
pattern: GlobPattern.from(filter.pattern),
|
||||
exclusive: filter.exclusive
|
||||
exclusive: filter.exclusive,
|
||||
notebookType: filter.notebookType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MarkdownString, NotebookCellOutputItem, NotebookData } from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { MarkdownString, NotebookCellOutputItem, NotebookData, LanguageSelector } from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { isEmptyObject } from 'vs/base/common/types';
|
||||
import { forEach } from 'vs/base/common/collections';
|
||||
import { LogLevel as _MainLogLevel } from 'vs/platform/log/common/log';
|
||||
|
@ -111,4 +111,16 @@ suite('ExtHostTypeConverter', function () {
|
|||
assert.strictEqual(item2.mime, item.mime);
|
||||
assert.deepStrictEqual(Array.from(item2.data), Array.from(item.data));
|
||||
});
|
||||
|
||||
test('LanguageSelector', function () {
|
||||
const out = LanguageSelector.from({ language: 'bat', notebookType: 'xxx' });
|
||||
assert.ok(typeof out === 'object');
|
||||
assert.deepStrictEqual(out, {
|
||||
language: 'bat',
|
||||
notebookType: 'xxx',
|
||||
scheme: undefined,
|
||||
pattern: undefined,
|
||||
exclusive: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue