Add lua script access to code using cx + reuse project search logic (#26269)

Access to `cx` will be needed for anything that queries entities. In
this commit this is use of `WorktreeStore::find_search_candidates`. In
the future it will be things like access to LSP / tree-sitter outlines /
etc.

Changes to support access to `cx` from functions provided to the Lua
script:

* Adds a channel of requests that require a `cx`. Work enqueued to this
channel is run on the foreground thread.

* Adds `async` and `send` features to `mlua` crate so that async rust
functions can be used from Lua.

* Changes uses of `Rc<RefCell<...>>` to `Arc<Mutex<...>>` so that the
futures are `Send`.

One benefit of reusing project search logic for search candidates is
that it properly ignores paths.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-03-07 03:02:49 -07:00 committed by GitHub
parent b0d1024f66
commit 205f9a9f03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 222 additions and 105 deletions

6
Cargo.lock generated
View file

@ -8134,6 +8134,7 @@ checksum = "d3f763c1041eff92ffb5d7169968a327e1ed2ebfe425dac0ee5a35f29082534b"
dependencies = [
"bstr",
"either",
"futures-util",
"mlua-sys",
"num-traits",
"parking_lot",
@ -11915,12 +11916,17 @@ version = "0.1.0"
dependencies = [
"anyhow",
"assistant_tool",
"futures 0.3.31",
"gpui",
"mlua",
"parking_lot",
"project",
"regex",
"schemars",
"serde",
"serde_json",
"smol",
"util",
"workspace",
]