Repository navigation
fix(node-dev): report search matches relative to custom_nodes/ so read can open them - #2930
Closed
wangzhengzhuo05 wants to merge 1 commit into
Closed
wangzhengzhuo05 wants to merge 1 commit into
wangzhengzhuo05 wants to merge 1 commit into
Conversation
…d can open them search's own `path` argument is the walk root, so matches were returned relative to it (a pack folder when path was a pack). read resolves against the custom_nodes/ base, so a search result could not be fed to read and failed with "File not found under custom_nodes/". Prefix reported paths with the walk root's offset from the base root; the default path "." is unchanged. Fixes artokun#2921
Contributor
Author
|
Closing this to keep the tracker clean \u2014 it has been sitting without review for several days. This is no reflection on the change itself: the fix and its local verification still stand. If the issue is still present and you would like the patch revisited, say the word and I will rebase it onto current main and re-open. Thanks for your time. |
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.
What
node_packactionsearchreported every match path relative to the search's ownpathwalk root, while
read/write/list_filesresolve theirpathargument against thecustom_nodes/base root. So a path returned bysearchcould not be fed back intoread: it failed withNODE_DEV_ERROR: File not found under custom_nodes/: "<path>".Reproduction from the issue: search with
pathset to a pack folder returnsweb/js/<file>.js, and the matchingreadlooks forcustom_nodes/web/js/<file>.js.The default
path: "."happened to work only because the walk root is the base root.How
In
searchNodePacks, compute the base root and the walk root's offset from it:Pass
relPrefixinto both engines and prepend it to the reportedfile:searchBuiltin:file: relPrefix ?${relPrefix}/${rel}: relsearchWithRipgrep:file: relPrefix ?${relPrefix}/${m[1]}: m[1]Behavior with the default
path: "."is unchanged (the prefix is empty), and thepath/globfiltering still matches against the search-dir-relative path so globsemantics are untouched.
Tests
Pack/nodes.py, search{ query: "FooNode", path: "Pack" },assert the reported file is
Pack/nodes.py, then feed that exact string toreadNodeFileand assert the content comes back — the full round trip from the issue.
mocked ripgrep seam.
npx vitest run src/__tests__/services/node-dev.test.ts→ 84 passednpx tsc --noEmit→ cleanMutation check
Reverting only the two
file:expressions to their pre-fix form makes both new tests fail(2 failed, 82 skipped); restoring the fix makes them pass. The new tests genuinely guard
the change.
Fixes #2921