Repository navigation
feat(core): restore and layer filename indexes across worktrees #873
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
Open
dmtrKovalenko
wants to merge
5
commits into
main
Choose a base branch
from
worktree-bridge-cse_01XRhTouiwMpb58un1nw46qg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c06f83
feat(core): restore and layer filename indexes across worktrees
dmtrKovalenko 9d90907
fix(core): keep index layer ids and explicit paths across watcher wri…
dmtrKovalenko d752313
fix(core): keep index layers stable across rescans and appends
dmtrKovalenko fc084cb
fix(query-parser): fix the clippy needless_bool lint from Rust 1.100
dmtrKovalenko 9c46615
test(core): fix the snapshot name count expected on Windows
dmtrKovalenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -552,7 +552,7 @@ Definition filtering occurs before page and per-file result limits. A timed-out | |
|
|
||
| Definition classification accepts source lines up to 256 bytes, including indentation and excluding line endings. Longer lines stay ordinary matches and are excluded from `definition_only`. The limit uses the original source bytes, regardless of display truncation or whitespace trimming. For multiline regex matches, it applies to the first physical line. | ||
|
|
||
| Supported language families are Rust, Python, Go, JavaScript/TypeScript, Lua, C/C++/Objective-C, Java/C#/Dart/Groovy, Kotlin, Scala, Swift, Ruby, Elixir, Zig, PHP, shell, OCaml/ReScript/F#, and Haskell. The byte-keyword rules in [`definition/languages.rs`](crates/fff-core/src/definition/languages.rs) compile into per-language checkers. Each checker has fixed grammar constants and returns a boolean without a runtime rule dispatcher. Language detection checks at most the last eight filename bytes against a compile-time suffix table. Unknown extensions and extensionless filenames are not classified. `definition_only` excludes them before sorting, pagination, or content reads, and preserves explicit file constraints on empty results. | ||
| Supported language families are Rust, Python, Go, JavaScript/TypeScript, Lua, C/C++/Objective-C, Java/C#/Dart/Groovy, Kotlin, Scala, Swift, Ruby, Zig, and OCaml/Reason/ReScript/F#. The byte-keyword rules in [`definition/languages.rs`](crates/fff-core/src/definition/languages.rs) compile into per-language checkers. Each checker has fixed grammar constants and returns a boolean without a runtime rule dispatcher. Language detection checks at most the last eight filename bytes against a compile-time suffix table. Unknown extensions and extensionless filenames are not classified. `definition_only` excludes them before sorting, pagination, or content reads, and preserves explicit file constraints on empty results. | ||
|
|
||
| Identifier scanning uses compile-time byte tables for short tokens, then checks 16 bytes at a time with NEON on little-endian ARM64 or SSE2 on x86-64. Other targets use the scalar table. Loads stay within the source slice, including the final partial block. The parser uses `memchr` for quotes and bracket groups and does not allocate. | ||
|
|
||
|
|
@@ -704,6 +704,12 @@ const hits = finder.value.grep("GetOffTheRecordProfile", { | |
| // Run extremely fast glob matching which is significantly (10-100 times) faster than Bun's and Node implementation | ||
| const rustFiles = finder.value.glob("**/*.rs", { pageSize: 100 }); | ||
|
|
||
| // Index layers: append paths the scanner can't see and persist any layer (0 = base scan) to a file | ||
| finder.value.createLayer("generated"); | ||
| finder.value.addPaths(["build/out/a.js", "build/out/b.js"]); | ||
| finder.value.saveLayer(0, "/tmp/base.fff"); // later: loadBase(...) skips the rescan | ||
| finder.value.loadLayer("/tmp/prebuilt.fff"); // built with FileFinder.buildLayerFile(paths, out) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build the file before loading it. This example never creates
|
||
|
|
||
| finder.value.destroy(); | ||
| ``` | ||
|
|
||
|
|
@@ -889,6 +895,22 @@ FffResult *res = fff_glob(handle, "**/*.rs", "", 0, 0, 100); | |
| // FffSearchResult in res->handle, free with fff_free_search_result. | ||
| ``` | ||
|
|
||
| ### Index layers | ||
|
|
||
| `fff_layer_create` / `fff_layer_add_paths` append paths the scanner can't see; | ||
| `fff_layer_save` writes any layer (0 = base scan) to a file and | ||
| `fff_layer_load` attaches it back as a sealed overlay. Layer IDs never change, and the | ||
| watcher writes only to layer 1. `fff_base_load` installs | ||
| it as the base scan in the background (wait with `fff_wait_for_scan`). | ||
| `fff_layer_build` packs a layer file without an instance. Pass NUL-terminated UTF-8 paths in one buffer, with optional parallel `sizes` / `modified` arrays (NULL to omit). | ||
|
|
||
| ```c | ||
| const char paths[] = "build/out/a.js\0build/out/b.js"; | ||
| struct FffResult *added = fff_layer_add_paths(handle, paths, sizeof(paths), NULL, NULL, 2); | ||
| if (!added->success) fprintf(stderr, "%s\n", added->error); | ||
| fff_free_result(added); | ||
| ``` | ||
|
|
||
| ### Notes | ||
|
|
||
| - Every function returning `FffResult*` allocates with Rust's `Box`. Free with `fff_free_result`, do not use malloc's free | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 8503
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 18718
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 12702
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 9162
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 11435
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 9145
Script executed:
Repository: dmtrKovalenko/fff
Length of output: 1238
Wait for index readiness before creating the layer.
waitForScancan return while indexing is active. ThencreateLayerfails.addPathscan also fail or, if indexing finishes between calls, write to the previous layer. Check the readiness result and each layer operation’sResultbefore continuing.