mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 02:48:30 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -12,17 +12,22 @@ export interface LanguageFilter {
|
||||
language?: string;
|
||||
scheme?: string;
|
||||
pattern?: string | IRelativePattern;
|
||||
/**
|
||||
* This provider is implemented in the UI thread.
|
||||
*/
|
||||
hasAccessToAllModels?: boolean;
|
||||
exclusive?: boolean;
|
||||
}
|
||||
|
||||
export type LanguageSelector = string | LanguageFilter | (string | LanguageFilter)[];
|
||||
|
||||
export function score(selector: LanguageSelector, candidateUri: URI, candidateLanguage: string): number {
|
||||
export function score(selector: LanguageSelector, candidateUri: URI, candidateLanguage: string, candidateIsSynchronized: boolean): number {
|
||||
|
||||
if (Array.isArray(selector)) {
|
||||
// array -> take max individual value
|
||||
let ret = 0;
|
||||
for (const filter of selector) {
|
||||
const value = score(filter, candidateUri, candidateLanguage);
|
||||
const value = score(filter, candidateUri, candidateLanguage, candidateIsSynchronized);
|
||||
if (value === 10) {
|
||||
return value; // already at the highest
|
||||
}
|
||||
@@ -33,9 +38,14 @@ export function score(selector: LanguageSelector, candidateUri: URI, candidateLa
|
||||
return ret;
|
||||
|
||||
} else if (typeof selector === 'string') {
|
||||
|
||||
if (!candidateIsSynchronized) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// short-hand notion, desugars to
|
||||
// 'fooLang' -> [{ language: 'fooLang', scheme: 'file' }, { language: 'fooLang', scheme: 'untitled' }]
|
||||
// '*' -> { language: '*', scheme: '*' }
|
||||
// 'fooLang' -> { language: 'fooLang'}
|
||||
// '*' -> { language: '*' }
|
||||
if (selector === '*') {
|
||||
return 5;
|
||||
} else if (selector === candidateLanguage) {
|
||||
@@ -46,7 +56,11 @@ export function score(selector: LanguageSelector, candidateUri: URI, candidateLa
|
||||
|
||||
} else if (selector) {
|
||||
// filter -> select accordingly, use defaults for scheme
|
||||
const { language, pattern, scheme } = selector;
|
||||
const { language, pattern, scheme, hasAccessToAllModels } = selector;
|
||||
|
||||
if (!candidateIsSynchronized && !hasAccessToAllModels) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let ret = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user