-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reload content on collections change (#966)
* fix: reload content on collections change * feat: reload the project on collections changes * test: add test * chore: changeset
- Loading branch information
1 parent
f1bdeab
commit 8673fa5
Showing
14 changed files
with
187 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@astrojs/language-server': patch | ||
'@astrojs/ts-plugin': patch | ||
'astro-vscode': patch | ||
--- | ||
|
||
Fixes certain cases where content schemas would not be reloaded properly when they were updated |
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
59 changes: 59 additions & 0 deletions
59
packages/language-server/test/content-intellisense/caching.test.ts
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,59 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import { Position } from '@volar/language-server'; | ||
import { expect } from 'chai'; | ||
import { before, describe, it } from 'mocha'; | ||
import { URI } from 'vscode-uri'; | ||
import { type LanguageServer, getLanguageServer } from '../server.js'; | ||
import { fixtureDir } from '../utils.js'; | ||
|
||
const contentSchemaPath = path.resolve(fixtureDir, '.astro', 'collections', 'caching.schema.json'); | ||
|
||
describe('Content Intellisense - Caching', async () => { | ||
let languageServer: LanguageServer; | ||
|
||
before(async () => (languageServer = await getLanguageServer())); | ||
|
||
it('Properly updates the schema when they are updated', async () => { | ||
const document = await languageServer.handle.openTextDocument( | ||
path.resolve(__dirname, '..', 'fixture', 'src', 'content', 'caching', 'caching.md'), | ||
'markdown', | ||
); | ||
|
||
const hover = await languageServer.handle.sendHoverRequest(document.uri, Position.create(1, 1)); | ||
|
||
expect(hover?.contents).to.deep.equal({ | ||
kind: 'markdown', | ||
value: 'I will be changed', | ||
}); | ||
|
||
fs.writeFileSync( | ||
contentSchemaPath, | ||
fs.readFileSync(contentSchemaPath, 'utf-8').replaceAll('I will be changed', 'I am changed'), | ||
); | ||
|
||
await languageServer.handle.didChangeWatchedFiles([ | ||
{ | ||
uri: URI.file(contentSchemaPath).toString(), | ||
type: 2, | ||
}, | ||
]); | ||
|
||
const hover2 = await languageServer.handle.sendHoverRequest( | ||
document.uri, | ||
Position.create(1, 1), | ||
); | ||
|
||
expect(hover2?.contents).to.deep.equal({ | ||
kind: 'markdown', | ||
value: 'I am changed', | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
fs.writeFileSync( | ||
contentSchemaPath, | ||
fs.readFileSync(contentSchemaPath, 'utf-8').replaceAll('I am changed', 'I will be changed'), | ||
); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/language-server/test/fixture/src/content/caching/caching.md
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,3 @@ | ||
--- | ||
title: 'A title' | ||
--- |
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
Oops, something went wrong.