-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update list of supported language Ids (#2796)
- Loading branch information
Showing
9 changed files
with
152 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import * as index from './index'; | ||
|
||
describe('settings/index', () => { | ||
test('', () => { | ||
test('index', () => { | ||
expect(typeof index.enableLocaleForTarget).toBe('function'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { readDefaults } from '../test/schema'; | ||
import { languageIds } from './languageIds'; | ||
|
||
describe('settings/index', () => { | ||
test('Default languageIds', async () => { | ||
const defaultSettings = await readDefaults(); | ||
const enabled = defaultSettings.get('cSpell.enabledLanguageIds'); | ||
await expect([...languageIds].sort()).toEqual((Array.isArray(enabled) ? [...enabled] : [enabled]).sort()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { promises as fs } from 'node:fs'; | ||
import * as path from 'node:path'; | ||
|
||
export const schemaFile = path.join(__dirname, '../../../_server/spell-checker-config.schema.json'); | ||
|
||
export async function readExtensionSchema(): Promise<Item> { | ||
const schema = await readJsonFile(schemaFile); | ||
return schema; | ||
} | ||
|
||
async function readJsonFile(filename: string) { | ||
return JSON.parse(await fs.readFile(filename, 'utf8')); | ||
} | ||
|
||
export async function readDefaults(): Promise<Map<string, unknown | undefined>> { | ||
const schema = await readExtensionSchema(); | ||
|
||
const items = Array.isArray(schema.items) ? schema.items : schema.items ? [schema.items] : []; | ||
|
||
const results = new Map<string, unknown | undefined>(); | ||
|
||
function processItem(item: Item) { | ||
if (!item.properties) return; | ||
Object.entries(item.properties).forEach(([k, v]) => results.set(k, v.default)); | ||
} | ||
|
||
items.forEach((element) => processItem(element)); | ||
|
||
return results; | ||
} | ||
|
||
interface Item { | ||
properties?: Record<string, Item>; | ||
items?: Item | Item[]; | ||
default?: unknown; | ||
} |