Skip to content

Apply schema associations without waiting for the file watcher - #427

Open
holodorum wants to merge 1 commit into
kson-org:mainfrom
holodorum:fix/schema-association-timing
Open

Apply schema associations without waiting for the file watcher#427
holodorum wants to merge 1 commit into
kson-org:mainfrom
holodorum:fix/schema-association-timing

Conversation

@holodorum

Copy link
Copy Markdown
Collaborator

The associate/remove schema commands write .kson-schema.kson from the server, but the server only reloaded its own FileSystemSchemaProvider once the client echoed that write back as workspace/didChangeWatchedFiles. On macOS that echo comes from FSEvents, so build-macos-arm64 flaked in the VS Code "Status Bar Schema Association" tests: the config file was on disk, yet completions and hover kept reporting no schema.

The server wrote the file, so it now picks the change up itself. CommandExecutor.node reloads the schema configuration and runs the same refresh-and-notify step the watcher handler uses; that step moves out of startKsonServer into core/schema/notifySchemaChange so every caller shares one implementation. The watcher path is unchanged -- it is still what catches edits made by the user or other tools -- and a watcher event arriving after a command simply repeats work already done.

The tests drive ASSOCIATE_SCHEMA and REMOVE_SCHEMA against a real temp workspace and assert the open document resolves its schema (down to the enum completions it enables) with no didChangeWatchedFiles event in sight.

The associate/remove schema commands write `.kson-schema.kson` from the
server, but the server only reloaded its own `FileSystemSchemaProvider` once
the client echoed that write back as `workspace`/`didChangeWatchedFiles`. On
macOS that echo comes from `FSEvents`, so `build-macos-arm64` flaked in
the VS Code "Status Bar Schema Association" tests: the config file was
on disk, yet completions and hover kept reporting no schema.

The server wrote the file, so it now picks the change up itself.
`CommandExecutor.node` reloads the schema configuration and runs the same
`refresh-and-notify` step the watcher handler uses; that step moves out of
`startKsonServer` into core/schema/notifySchemaChange so every caller shares
one implementation. The watcher path is unchanged -- it is still what
catches edits made by the user or other tools -- and a watcher event
arriving after a command simply repeats work already done.

The tests drive ASSOCIATE_SCHEMA and REMOVE_SCHEMA against a real temp
workspace and assert the open document resolves its schema (down to the
enum completions it enables) with no didChangeWatchedFiles event in sight.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant