Repository navigation
fix: make F5 work again and support koishi.yaml - #9
Merged
Merged
Conversation
The schemata/*.json and snippets/*.json files are generated from their .yaml sources and are gitignored, so a fresh clone has none of them. The default build task only ran `yarn run watch` (tsc), so the Extension Development Host started with the JSON missing and activate() threw "Schema not found". Chain a `generate schemata` task ahead of the watcher. Note that Yarn 4 no longer runs pre/post scripts, so a prewatch script would not have worked.
VS Code no longer supports the `${defaultBuildTask}` variable, so pressing F5
reported "Task '${defaultBuildTask}' not found". Name the task directly.
The label is "watch: compile" rather than "npm: watch" because VS Code
auto-detects package.json scripts under that same identifier; a duplicate
identifier makes F5 prompt for a task picker instead of running the task.
The document selector and the yamlValidation fileMatch both only listed koishi.yml, so a project using the .yaml spelling got no schema validation, completion, hover or go to definition at all. Widen both patterns to a brace glob. Verified the brace form matches koishi.yml and koishi.yaml in any directory while still rejecting my-koishi.yml, other.yml and koishi.yml.bak.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Pressing F5 failed with
Task '${defaultBuildTask}' not found, and after fixing that the Extension Development Host crashed on startup withSchema not found: .../schemata/koishi-yml.json. Separately, projects using thekoishi.yamlspelling got no validation, completion, hover or go to definition at all.Both of the F5 problems had been present since the initial commit, so nobody could run the extension locally.
Approach
Make F5 generate the schemata before compiling.
schemata/*.jsonandsnippets/*.jsonare generated from their.yamlsources and are gitignored, so a fresh clone has none of them. The default build task only rantsc, so the Extension Development Host started against a missing schema. Agenerate schematatask now runs ahead of the watcher viadependsOn.Stop using the
${defaultBuildTask}variable. VS Code removed support for it, solaunch.jsonnames the task directly now.Two details worth a look during review:
watch: compile, notnpm: watch. VS Code auto-detectspackage.jsonscripts under that exact identifier, and a duplicate makes F5 prompt for a task picker instead of running the task directly.prewatchscript would not have worked. This project is on Yarn 4, which no longer runspre/postscripts; onlynpmdoes. I verified this empirically, which is why the fix is a task chain rather than a script hook.Widen the file matching to both spellings. The document selector and the
yamlValidationfileMatch both listed onlykoishi.yml. Both are now brace globs (koishi.{yml,yaml}).The obvious alternative spelling,
**/koishi*.ymlor**/*.yml, would have been wrong: it would apply Koishi's schema to every YAML file in a user's project. I verified the brace form againstmy-koishi.yml,other.yml,koishiyamlandkoishi.yml.bakto confirm it stays narrow.Test note
The existing test
the selector targets koishi.yml onlyasserted a literal pattern string, so it would have kept passing after the glob change and silently stopped testing anything. It now asserts the new pattern, plus a check that the pattern is not widened to*.yml.Verification
yarn test: 63 passing (includes a real VS Code instance), confirmed the updated selector test actually runsyarn run lintandyarn run compile: cleanout/and the generated JSON) and ran the fulldependsOnchain: schema generated, compiled,activate()loads successfullyOne caveat: I could not launch the Extension Development Host directly to press F5 myself, so the task resolution was verified by simulating the chain VS Code runs rather than by clicking F5.
Note that a third error some people hit,
Configured debug type 'extensionHost' is not supported, is unrelated to this repo: it means the built-injs-debugextension is disabled, not thatlaunch.jsonis wrong.extensionHostis a valid type and is what the official generator and 63 samples invscode-extension-samplesuse.