-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Ignore non-Minecraft JSON files #1758
base: main
Are you sure you want to change the base?
Conversation
Files of `.json` extension now must also pass a URI predicate check before they are considered to be `json` language and be supported by Spyglass.
getTrackedFiles(): string[] { | ||
const extensions: string[] = this.meta.getSupportedFileExtensions() | ||
this.logger.info(`[Project#getTrackedFiles] Supported file extensions: ${extensions}`) | ||
const supportedFiles = [...this.#dependencyFiles ?? [], ...this.#watchedFiles] | ||
.filter((file) => extensions.includes(fileUtil.extname(file) ?? '')) | ||
this.logger.info( | ||
`[Project#getTrackedFiles] Listed ${supportedFiles.length} supported files`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extension check here has been removed as all files in #dependencyFiles
and #watchedFiles
should now all be of supported languages already.
Files of unsupported languages should now never enter into the Spyglass document lifecycle.
123c813
to
526a13c
Compare
candidateResources.push([res, identifier]) | ||
} | ||
} | ||
const candidateResources = getCandidateResourcesForRel(rel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic between const parts = res.split('/')
and here is also duplicated in getCandidateResourcesForRel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's cuz we use the value of namespace
below and I did not want to make getCandidateResourcesForRel()
return two things (getCandidateResourcesAndNamespaceForRel()
?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I see. Though it already returns a list of two things: function getCandidateResourcesForRel(rel: string): [res: Resource, identifier: string][]
, so maybe it wouldn't be that bad to have it also return the namespace in that tuple (or change to an object)?
(This PR could have each commit individually merged instead of a squash merge since I separated units of change into four individually revertable commits. Well after a
git rebase --autosquash -i 3ea96b
that is)This PR adds an additional
uriPredicate
option toLanguageOptions
during language registration. Thejson
language definition has been updated to include auriPredicate
to ensure the JSON file actually belongs to a data pack or a resource pack. This check is more accurate than theDocumentFilter
implemented client side in the VS Code extension as it takes the roots and the available file categories into consideration. Additions have also been made toProject.shouldExclude()
to make sure unsupported files never go into the document life cycle.This PR also fixes two bugs I noticed while making the changes.