docs: state the code-language comments as current contracts

The new JSDoc and test prose narrated the change instead of the shipped
behavior: "pre-unification", "the old read table", "used to persist ... it
now persists". A reader at HEAD cannot resolve those stages, and the
persisted-value rule they describe is a durability contract that stands on
its own.

Restate each as the present contract: a suffix whose value a recorded
session already holds keeps it byte-identical; every other suffix takes its
language's short name. Rename the test's transcribed expectation away from
the branch vantage and re-wrap the module comment the earlier edit left
over-long.
This commit is contained in:
mektpoy committed 2026-09-23 14:23:07 +08:00
1 parent 5774f385f4
commit 88b1ea3c0b
6 files changed
+58 -55

No files matched your search

@@ -32,7 +32,7 @@ describe('languageForPath', () => {
expect(languageForPath(path)).toBe(language)
})
it('keeps the extensions the two former tables already agreed on', () => {
it('resolves the extensions the preview and read tables already agreed on', () => {
expect(languageForPath('src/a.ts')).toBe('typescript')
expect(languageForPath('src/a.TSX')).toBe('typescript')
expect(languageForPath('/abs/module.mjs')).toBe('javascript')
@@ -41,7 +41,7 @@ describe('languageForPath', () => {
expect(languageForPath('C:\\src\\main.rs')).toBe('rust')
})
it('resolves every extension that only the preview table knew, including the new ones', () => {
it('resolves every suffix the preview registry declares beyond the persisted read hints', () => {
for (const extension of ['jsonl', 'ndjson', 'pyw', 'pyi', 'rake', 'gemspec', 'hh', 'hxx', 'kts', 'xhtml', 'xsd', 'xsl', 'xslt']) {
expect(languageForPath(`file.${extension}`), extension).toBeDefined()
}
@@ -91,7 +91,7 @@ describe('languageForPath', () => {
})
describe('readLangHintForPath', () => {
it('keeps the read card pre-unification short hints for the old suffixes', () => {
it('keeps the read card short hints recorded sessions already hold', () => {
expect(readLangHintForPath('src/a.ts')).toBe('ts')
expect(readLangHintForPath('src/a.tsx')).toBe('tsx')
expect(readLangHintForPath('src/a.mts')).toBe('ts')
@@ -110,7 +110,7 @@ describe('readLangHintForPath', () => {
expect(readLangHintForPath('page.htm')).toBe('html')
})
it('uses the language short id for a suffix added after the old read table', () => {
it('uses the language short id for a suffix with no persisted value', () => {
expect(readLangHintForPath('build.ps1')).toBe('ps1')
expect(readLangHintForPath('.env')).toBe('env')
expect(readLangHintForPath('infra.tf')).toBe('tf')
@@ -137,11 +137,12 @@ describe('readLangHintForPath', () => {
}
it('persists a short id for every suffix, never a canonical grammar id', () => {
// The persisted `lang` has one style: the historical short id for the
// suffixes the old read table knew, the language's short name otherwise. A
// result outside both sets is a canonical grammar id leaking back in
// (`powershell`, `dotenv`, `latex`, `hcl`). The old table's `tsx`/`jsx`
// hints are the only legacy values absent from the short-name table.
// The persisted `lang` has one style: a short id. Every suffix must resolve
// to one of these short names, except the persisted `tsx`/`jsx` values,
// which the language table cannot express because typescript and javascript
// already shorten to `ts` and `js`. A result outside both sets is a
// canonical grammar id leaking back in (`powershell`, `dotenv`, `latex`,
// `hcl`).
const allowed = new Set([...Object.values(SHORT_BY_LANGUAGE), 'tsx', 'jsx'])
for (const extension of CODE_HIGHLIGHT_EXTENSIONS) {
const hint = readLangHintForPath(`file.${extension}`)