Fix soft-wrapping with fold creases (#28029)
Release Notes: - Fixed a rendering bug that caused context in the agent to not wrap properly. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> Co-authored-by: Zed AI <ai+claude-3.7@zed.dev>
This commit is contained in:
parent
ed3722023e
commit
e123c4bced
9 changed files with 456 additions and 128 deletions
|
@ -25,8 +25,8 @@ use collections::HashMap;
|
|||
use fs::MTime;
|
||||
use futures::channel::oneshot;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, EventEmitter, HighlightStyle, Pixels,
|
||||
SharedString, StyledText, Task, TaskLabel, TextStyle, Window,
|
||||
App, AppContext as _, Context, Entity, EventEmitter, HighlightStyle, SharedString, StyledText,
|
||||
Task, TaskLabel, TextStyle,
|
||||
};
|
||||
use lsp::{LanguageServerId, NumberOrString};
|
||||
use parking_lot::Mutex;
|
||||
|
@ -43,14 +43,13 @@ use std::{
|
|||
cmp::{self, Ordering, Reverse},
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ffi::OsStr,
|
||||
fmt,
|
||||
future::Future,
|
||||
iter::{self, Iterator, Peekable},
|
||||
mem,
|
||||
num::NonZeroU32,
|
||||
ops::{Deref, DerefMut, Range},
|
||||
ops::{Deref, Range},
|
||||
path::{Path, PathBuf},
|
||||
rc, str,
|
||||
rc,
|
||||
sync::{Arc, LazyLock},
|
||||
time::{Duration, Instant},
|
||||
vec,
|
||||
|
@ -483,45 +482,6 @@ pub struct Chunk<'a> {
|
|||
pub is_unnecessary: bool,
|
||||
/// Whether this chunk of text was originally a tab character.
|
||||
pub is_tab: bool,
|
||||
/// An optional recipe for how the chunk should be presented.
|
||||
pub renderer: Option<ChunkRenderer>,
|
||||
}
|
||||
|
||||
/// A recipe for how the chunk should be presented.
|
||||
#[derive(Clone)]
|
||||
pub struct ChunkRenderer {
|
||||
/// creates a custom element to represent this chunk.
|
||||
pub render: Arc<dyn Send + Sync + Fn(&mut ChunkRendererContext) -> AnyElement>,
|
||||
/// If true, the element is constrained to the shaped width of the text.
|
||||
pub constrain_width: bool,
|
||||
}
|
||||
|
||||
pub struct ChunkRendererContext<'a, 'b> {
|
||||
pub window: &'a mut Window,
|
||||
pub context: &'b mut App,
|
||||
pub max_width: Pixels,
|
||||
}
|
||||
|
||||
impl fmt::Debug for ChunkRenderer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("ChunkRenderer")
|
||||
.field("constrain_width", &self.constrain_width)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ChunkRendererContext<'_, '_> {
|
||||
type Target = App;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.context
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for ChunkRendererContext<'_, '_> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.context
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of edits to a given version of a buffer, computed asynchronously.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue