Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
"preLaunchTask": "watch: compile"
},
{
"name": "Extension Tests",
Expand All @@ -28,7 +28,7 @@
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
"preLaunchTask": "watch: compile"
}
]
}
23 changes: 23 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,33 @@
"version": "2.0.0",
"tasks": [
{
// The schemata/*.json and snippets/*.json files are generated from their
// .yaml sources and are gitignored, so a fresh clone has none of them.
// `yarn run watch` only runs tsc, so without this task the Extension
// Development Host starts with the JSON missing and activate() throws
// "Schema not found". Generate them before the watcher starts.
"label": "generate schemata",
"type": "npm",
"script": "convert",
"problemMatcher": [],
"presentation": {
"reveal": "never"
}
},
{
// Labelled explicitly so launch.json can reference it by name.
// VS Code dropped support for the `${defaultBuildTask}` variable, which
// resolves to the "Task not found" error reported when pressing F5.
// The label is deliberately not "npm: watch": VS Code also auto-detects
// package.json scripts under that exact identifier, and a duplicate
// identifier makes F5 prompt for a task instead of running this one.
"label": "watch: compile",
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"dependsOn": "generate schemata",
"dependsOrder": "sequence",
"presentation": {
"reveal": "never"
},
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

### Added

- Support `koishi.yaml` alongside `koishi.yml`. Both spellings now get schema
validation, completion, hover and go to definition.
- Add field, enum and plugin name completion for `koishi.yml`. Plugin names come
from a bundled snapshot of the official plugins merged with the plugins
installed in the current workspace.
Expand All @@ -20,6 +22,16 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

### Fixed

- Fix F5 reporting `Task '${defaultBuildTask}' not found`. VS Code no longer
supports that variable, so `launch.json` now names the build task directly.
The task is labelled `watch: compile` rather than `npm: watch`, because VS
Code auto-detects `package.json` scripts under that same identifier and the
duplicate makes F5 prompt for a task instead of running it.
- Fix F5 failing to start the Extension Development Host on a fresh clone. The
`schemata/*.json` and `snippets/*.json` files are generated from their `.yaml`
sources and are gitignored, but the default build task only ran `tsc`, so
activation threw `Schema not found: .../schemata/koishi-yml.json`. The default
build task now runs the conversion first.
- Compile `src/test` as part of `yarn run compile`, so `yarn test` can find the
test files it previously never built.
- Update the Mocha test runner for the current `glob` and `mocha` releases.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
],
"yamlValidation": [
{
"fileMatch": "koishi.yml",
"fileMatch": "koishi.{yml,yaml}",
"url": "./schemata/koishi-yml.json"
}
],
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { KoishiDefinitionProvider } from './providers/definition'

/** Documents this extension contributes language intelligence for. */
export const KOISHI_YML_SELECTOR: vscode.DocumentSelector = [
{ language: 'yaml', scheme: 'file', pattern: '**/koishi.yml' },
{ language: 'yaml', scheme: 'untitled', pattern: '**/koishi.yml' },
{ language: 'yaml', scheme: 'file', pattern: '**/koishi.{yml,yaml}' },
{ language: 'yaml', scheme: 'untitled', pattern: '**/koishi.{yml,yaml}' },
]

export function activate(context: vscode.ExtensionContext): void {
Expand Down
6 changes: 4 additions & 2 deletions src/test/suite/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ suite('providers', () => {
for (const subscription of subscriptions) {subscription.dispose()}
})

test('the selector targets koishi.yml only', () => {
test('the selector targets koishi.yml and koishi.yaml only', () => {
const selector = KOISHI_YML_SELECTOR as Array<Record<string, string>>
assert.ok(selector.some((s) => s.pattern === '**/koishi.yml'))
assert.ok(selector.some((s) => s.pattern === '**/koishi.{yml,yaml}'))
assert.ok(selector.every((s) => s.language === 'yaml'))
// The brace pattern must not widen the match to unrelated YAML files.
assert.ok(selector.every((s) => !s.pattern.includes('*.yml')))
})
})

Expand Down
Loading