Rework context insertion UX (#12360)
- Confirming a completion now runs the command immediately - Hitting `enter` on a line with a command now runs it - The output of commands gets folded away and replaced with a custom placeholder - Eliminated ambient context <img width="1588" alt="image" src="https://github.com/zed-industries/zed/assets/482957/b1927a45-52d6-4634-acc9-2ee539c1d89a"> Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
20f37f0647
commit
7e3ab9acc9
@@ -36,7 +36,13 @@ impl FlapSnapshot {
|
||||
while let Some(item) = cursor.item() {
|
||||
match Ord::cmp(&item.flap.range.start.to_point(snapshot).row, &row.0) {
|
||||
Ordering::Less => cursor.next(snapshot),
|
||||
Ordering::Equal => return Some(&item.flap),
|
||||
Ordering::Equal => {
|
||||
if item.flap.range.start.is_valid(snapshot) {
|
||||
return Some(&item.flap);
|
||||
} else {
|
||||
cursor.next(snapshot);
|
||||
}
|
||||
}
|
||||
Ordering::Greater => break,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ pub struct FoldPlaceholder {
|
||||
pub render: Arc<dyn Send + Sync + Fn(FoldId, Range<Anchor>, &mut WindowContext) -> AnyElement>,
|
||||
/// If true, the element is constrained to the shaped width of an ellipsis.
|
||||
pub constrain_width: bool,
|
||||
/// If true, merges the fold with an adjacent one.
|
||||
pub merge_adjacent: bool,
|
||||
}
|
||||
|
||||
impl FoldPlaceholder {
|
||||
@@ -30,6 +32,7 @@ impl FoldPlaceholder {
|
||||
Self {
|
||||
render: Arc::new(|_id, _range, _cx| gpui::Empty.into_any_element()),
|
||||
constrain_width: true,
|
||||
merge_adjacent: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,8 +377,11 @@ impl FoldMap {
|
||||
|
||||
assert!(fold_range.start.0 >= sum.input.len);
|
||||
|
||||
while folds.peek().map_or(false, |(_, next_fold_range)| {
|
||||
next_fold_range.start <= fold_range.end
|
||||
while folds.peek().map_or(false, |(next_fold, next_fold_range)| {
|
||||
next_fold_range.start < fold_range.end
|
||||
|| (next_fold_range.start == fold_range.end
|
||||
&& fold.placeholder.merge_adjacent
|
||||
&& next_fold.placeholder.merge_adjacent)
|
||||
}) {
|
||||
let (_, next_fold_range) = folds.next().unwrap();
|
||||
if next_fold_range.end > fold_range.end {
|
||||
|
||||
Reference in New Issue
Block a user