Start on a database-backed prompt library (#12468)

Using the file system as a database seems like it's easy, but it's
actually a real pain. I'd like to use LMDB to store the prompts locally
so we have more control. We can always add an export option, but I want
the source of truth to be somewhere other than the file system.

So far, I have a PromptStore which is global to the application and can
be initialized on startup. Then there's a `PromptLibrary` which is
intended to be the root of a new kind of Zed window. I haven't actually
seen pixels yet, but I've sketched out the basics needed to create a new
prompt, save, etc.

Still lots to figure out but the foundations of being backed by a DB and
rendering in an independent window are in place.

/cc @iamnbutler @as-cii 

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2024-06-03 07:58:43 -06:00 committed by GitHub
parent 18e2b43d6d
commit 5f98b9617a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1427 additions and 1429 deletions

View file

@ -1,9 +1,9 @@
use editor::{scroll::Autoscroll, Anchor, Editor, ExcerptId};
use gpui::{
actions, canvas, div, rems, uniform_list, AnyElement, AppContext, Div, EventEmitter,
FocusHandle, FocusableView, Hsla, InteractiveElement, IntoElement, Model, MouseButton,
MouseDownEvent, MouseMoveEvent, ParentElement, Render, Styled, UniformListScrollHandle, View,
ViewContext, VisualContext, WeakView, WindowContext,
actions, div, rems, uniform_list, AnyElement, AppContext, Div, EventEmitter, FocusHandle,
FocusableView, Hsla, InteractiveElement, IntoElement, Model, MouseButton, MouseDownEvent,
MouseMoveEvent, ParentElement, Render, Styled, UniformListScrollHandle, View, ViewContext,
VisualContext, WeakView, WindowContext,
};
use language::{Buffer, OwnedSyntaxLayer};
use std::{mem, ops::Range};
@ -281,7 +281,7 @@ impl Render for SyntaxTreeView {
.and_then(|buffer| buffer.active_layer.as_ref())
{
let layer = layer.clone();
let mut list = uniform_list(
rendered = rendered.child(uniform_list(
cx.view().clone(),
"SyntaxTreeView",
layer.node().descendant_count(),
@ -360,18 +360,7 @@ impl Render for SyntaxTreeView {
)
.size_full()
.track_scroll(self.list_scroll_handle.clone())
.text_bg(cx.theme().colors().background).into_any_element();
rendered = rendered.child(
canvas(
move |bounds, cx| {
list.prepaint_as_root(bounds.origin, bounds.size.into(), cx);
list
},
|_, mut list, cx| list.paint(cx),
)
.size_full(),
);
.text_bg(cx.theme().colors().background).into_any_element());
}
rendered