[WIP] Parse "scripts" values in package.json as Bash #826
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.
What
Parse the string values inside
"scripts"
in a JSON file (targetingpackage.json
files) as languageBash
.Why
To get a more minimal diff of those script values when only a small part of the shell script is changed
Todo
package.json
or some pattern closely matching thatname
andversion
and other telltale top-level properties characterizing apackage.json
fileStatus
The sublanguage detection does work, as confirmed when I insert
dbg!
statements intoparse_subtrees
: the intended nodes are recognized and recorded in thesubtrees
hashmap that's returned.But that's not having the intended effect and I'm not sure why. The changed subparts of the script string do get highlighted individually, but the whole script string is red in the original and green in the current file:

What I was after was the same behavior I see with the existing sub-language setup for Css in the

style
element of an Html tree, where only the changed parts of the subtree are colored red and green:The Bash language does do that minimal diffing, when I extract those shell strings to files and difft them directly:

So why don't I get that behavior when these shell strings are diffed in sub-language subtrees?
Example files
package-orig.json
:package-changed.json
: