Repository navigation
Sync open pxt.json editor buffer when package config is updated - #11666
Open
Dmitriy Antipov (THEb0nny) wants to merge 1 commit into
Open
Dmitriy Antipov (THEb0nny) wants to merge 1 commit into
Dmitriy Antipov (THEb0nny) wants to merge 1 commit into
Conversation
Contributor
Author
|
The bug was discovered while working with the new filelist rename function. |
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.
Summary
Fixes an issue where
pxt.jsondoes not update when open in the editor (Monaco text editor or project settings) while project files or dependencies are added, renamed, or deleted.Root Cause
When files or dependencies are added, renamed, or removed,
updateConfigAsyncupdatespxt.jsonon disk and incfgFile.content. However:pxt.jsonis currently open in the Monaco text editor, Monaco's in-memory model (pkg:pxt.json) was not being updated.setContentAsyncwas called withoutforce = true, so change listeners were not notified.saveCurrentSourceAsyncread from the stale Monaco buffer and saved the old text back intopxt.json, undoing the file addition, rename, or deletion.Changes
webapp/src/package.ts(updateConfigAsync):pxtJsonModel.setValue(newContent)) with the new JSON config so the UI updates immediately and subsequent saves use the new content.force = truetosetContentAsyncto notify listeners of programmatic changes.webapp/src/pxtjson.tsx(pxtjson.Editor):setForceChangeCallbackso the visual settings editor also refreshes automatically when the config changes externally.Videos
Before (bug):
https://github.com/user-attachments/assets/e27ffa94-9854-469a-b53b-908811e7d979
After (fixed):
https://github.com/user-attachments/assets/04db5a57-4231-4697-b1c6-0b52f53ead5f