Introduce custom fold placeholders (#12214)

This pull request replaces the static `⋯` character we used to insert
when folding a range with a custom render function that return an
`AnyElement`. We plan to use this in the assistant, but for now this
should be behavior-preserving.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-05-23 23:22:30 +02:00 committed by GitHub
parent e0cfba43aa
commit 57d570c281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 774 additions and 437 deletions

View file

@ -189,7 +189,7 @@ pub struct LanguageModelChoiceDelta {
struct MessageMetadata {
role: Role,
status: MessageStatus,
// todo!("delete this")
// TODO: Delete this
#[serde(skip)]
ambient_context: AmbientContextSnapshot,
}

View file

@ -19,6 +19,7 @@ use crate::{
use anyhow::{anyhow, Result};
use client::telemetry::Telemetry;
use collections::{hash_map, HashMap, HashSet, VecDeque};
use editor::FoldPlaceholder;
use editor::{
actions::{FoldAt, MoveDown, MoveUp},
display_map::{
@ -34,7 +35,7 @@ use fs::Fs;
use futures::StreamExt;
use gpui::{
canvas, div, point, relative, rems, uniform_list, Action, AnyElement, AnyView, AppContext,
AsyncAppContext, AsyncWindowContext, AvailableSpace, ClipboardItem, Context, Entity,
AsyncAppContext, AsyncWindowContext, AvailableSpace, ClipboardItem, Context, Empty, Entity,
EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, HighlightStyle,
InteractiveElement, IntoElement, Model, ModelContext, ParentElement, Pixels, Render,
SharedString, StatefulInteractiveElement, Styled, Subscription, Task, TextStyle,
@ -2943,6 +2944,10 @@ impl ConversationEditor {
.insert_flaps(
[Flap::new(
start..end,
FoldPlaceholder {
render: Arc::new(|_, _, _| Empty.into_any()),
constrain_width: false,
},
render_slash_command_output_toggle,
render_slash_command_output_trailer,
)],