Compare commits

...

8 Commits

Author SHA1 Message Date
Joseph T. Lyons
69dbfe78d5 v0.102.x stable 2023-09-06 12:52:35 -04:00
Conrad Irwin
2124c47653 Fix accidental visual selection on scroll (#2927)
Release Notes:

- vim: Fix bug where scrolling vertically would sometimes enter visual
mode
2023-09-04 14:47:32 -04:00
Antonio Scandurra
d55132c1e8 Avoid duplicate entries in inline assistant's prompt history (#2926)
Release Notes:

- Improved the inline assistant's prompt history to avoid including the
same entry multiple times. (preview-only)
2023-09-01 09:21:59 +02:00
Kirill Bulatov
df3dccc23f Use ctrl-: instead of ctrl-shift-: for inlay hints toggling (#2921)
The latter is not possible to press in Zed, since `:` is typed as
`shift-;` with typical US keyboard layouts.

In the end, it's the same buttons you have to press to toggle the inlay
hints, but working this time.

Release Notes:

- N/A
2023-08-31 18:59:47 +03:00
Max Brunsfeld
aff0e9019e zed 0.102.1 2023-08-30 15:11:25 -07:00
Max Brunsfeld
935dcee510 Disable save as prompt for channel notes (#2917) 2023-08-30 15:10:13 -07:00
Max Brunsfeld
f872d2e473 Fix collab panel regressions (#2915)
Release Notes:

- Fixed a bug where collaborators' cursors were rendered with the wrong
color when not following them (preview only).
- Fixed an issue where icons were inconsistent sizes in the
collaboration panel (preview only).
2023-08-30 14:42:31 -07:00
Joseph T. Lyons
2aa94f3052 v0.102.x preview 2023-08-30 13:40:36 -04:00
11 changed files with 89 additions and 76 deletions

2
Cargo.lock generated
View File

@@ -9702,7 +9702,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.102.0"
version = "0.102.1"
dependencies = [
"activity_indicator",
"ai",

View File

@@ -522,7 +522,7 @@
// TODO: Move this to a dock open action
"cmd-shift-c": "collab_panel::ToggleFocus",
"cmd-alt-i": "zed::DebugElements",
"ctrl-shift-:": "editor::ToggleInlayHints",
"ctrl-:": "editor::ToggleInlayHints",
}
},
{

View File

@@ -513,10 +513,13 @@ impl AssistantPanel {
return;
};
self.inline_prompt_history
.retain(|prompt| prompt != user_prompt);
self.inline_prompt_history.push_back(user_prompt.into());
if self.inline_prompt_history.len() > Self::INLINE_PROMPT_HISTORY_MAX_LEN {
self.inline_prompt_history.pop_front();
}
let range = pending_assist.range.clone();
let snapshot = editor.read(cx).buffer().read(cx).snapshot(cx);
let selected_text = snapshot

View File

@@ -213,7 +213,7 @@ impl Item for ChannelView {
}
fn is_singleton(&self, _cx: &AppContext) -> bool {
true
false
}
fn navigate(&mut self, data: Box<dyn Any>, cx: &mut ViewContext<Self>) -> bool {

View File

@@ -1106,23 +1106,17 @@ impl CollabPanel {
) -> AnyElement<Self> {
enum OpenSharedScreen {}
let font_cache = cx.font_cache();
let host_avatar_height = theme
let host_avatar_width = theme
.contact_avatar
.width
.or(theme.contact_avatar.height)
.unwrap_or(0.);
let row = &theme.project_row.inactive_state().default;
let tree_branch = theme.tree_branch;
let line_height = row.name.text.line_height(font_cache);
let cap_height = row.name.text.cap_height(font_cache);
let baseline_offset =
row.name.text.baseline_offset(font_cache) + (theme.row_height - line_height) / 2.;
MouseEventHandler::new::<OpenSharedScreen, _>(
peer_id.as_u64() as usize,
cx,
|mouse_state, _| {
|mouse_state, cx| {
let tree_branch = *tree_branch.in_state(is_selected).style_for(mouse_state);
let row = theme
.project_row
@@ -1130,49 +1124,20 @@ impl CollabPanel {
.style_for(mouse_state);
Flex::row()
.with_child(
Stack::new()
.with_child(Canvas::new(move |scene, bounds, _, _, _| {
let start_x = bounds.min_x() + (bounds.width() / 2.)
- (tree_branch.width / 2.);
let end_x = bounds.max_x();
let start_y = bounds.min_y();
let end_y = bounds.min_y() + baseline_offset - (cap_height / 2.);
scene.push_quad(gpui::Quad {
bounds: RectF::from_points(
vec2f(start_x, start_y),
vec2f(
start_x + tree_branch.width,
if is_last { end_y } else { bounds.max_y() },
),
),
background: Some(tree_branch.color),
border: gpui::Border::default(),
corner_radii: (0.).into(),
});
scene.push_quad(gpui::Quad {
bounds: RectF::from_points(
vec2f(start_x, end_y),
vec2f(end_x, end_y + tree_branch.width),
),
background: Some(tree_branch.color),
border: gpui::Border::default(),
corner_radii: (0.).into(),
});
}))
.constrained()
.with_width(host_avatar_height),
)
.with_child(render_tree_branch(
tree_branch,
&row.name.text,
is_last,
vec2f(host_avatar_width, theme.row_height),
cx.font_cache(),
))
.with_child(
Svg::new("icons/disable_screen_sharing_12.svg")
.with_color(row.icon.color)
.with_color(theme.channel_hash.color)
.constrained()
.with_width(row.icon.width)
.with_width(theme.channel_hash.width)
.aligned()
.left()
.contained()
.with_style(row.icon.container),
.left(),
)
.with_child(
Label::new("Screen", row.name.text.clone())
@@ -2553,27 +2518,16 @@ impl View for CollabPanel {
.with_child(
Flex::column()
.with_child(
Flex::row()
.with_child(
ChildView::new(&self.filter_editor, cx)
.contained()
.with_style(theme.user_query_editor.container)
.flex(1.0, true),
)
.constrained()
.with_width(self.size(cx)),
)
.with_child(
List::new(self.list_state.clone())
.constrained()
.with_width(self.size(cx))
.flex(1., true)
.into_any(),
Flex::row().with_child(
ChildView::new(&self.filter_editor, cx)
.contained()
.with_style(theme.user_query_editor.container)
.flex(1.0, true),
),
)
.with_child(List::new(self.list_state.clone()).flex(1., true).into_any())
.contained()
.with_style(theme.container)
.constrained()
.with_width(self.size(cx))
.into_any(),
)
.with_children(

View File

@@ -1559,7 +1559,7 @@ impl Editor {
.excerpt_containing(self.selections.newest_anchor().head(), cx)
}
fn style(&self, cx: &AppContext) -> EditorStyle {
pub fn style(&self, cx: &AppContext) -> EditorStyle {
build_style(
settings::get::<ThemeSettings>(cx),
self.get_field_editor_theme.as_deref(),

View File

@@ -2251,7 +2251,7 @@ impl Element<Editor> for EditorElement {
let replica_id = if let Some(mapping) = &editor.replica_id_mapping {
mapping.get(&replica_id).copied()
} else {
None
Some(replica_id)
};
// The local selections match the leader's selections.

View File

@@ -39,7 +39,7 @@ impl ScrollAmount {
.visible_line_count()
// subtract one to leave an anchor line
// round towards zero (so page-up and page-down are symmetric)
.map(|l| ((l - 1.) * count).trunc())
.map(|l| (l * count).trunc() - count.signum())
.unwrap_or(0.),
}
}

View File

@@ -67,7 +67,8 @@ fn scroll_editor(editor: &mut Editor, amount: &ScrollAmount, cx: &mut ViewContex
let top_anchor = editor.scroll_manager.anchor().anchor;
editor.change_selections(None, cx, |s| {
s.move_heads_with(|map, head, goal| {
s.move_with(|map, selection| {
let head = selection.head();
let top = top_anchor.to_display_point(map);
let min_row = top.row() + VERTICAL_SCROLL_MARGIN as u32;
let max_row = top.row() + visible_rows - VERTICAL_SCROLL_MARGIN as u32 - 1;
@@ -79,7 +80,11 @@ fn scroll_editor(editor: &mut Editor, amount: &ScrollAmount, cx: &mut ViewContex
} else {
head
};
(new_head, goal)
if selection.is_empty() {
selection.collapse_to(new_head, selection.goal)
} else {
selection.set_head(new_head, selection.goal)
};
})
});
}
@@ -90,12 +95,35 @@ mod test {
use crate::{state::Mode, test::VimTestContext};
use gpui::geometry::vector::vec2f;
use indoc::indoc;
use language::Point;
#[gpui::test]
async fn test_scroll(cx: &mut gpui::TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await;
cx.set_state(indoc! {"ˇa\nb\nc\nd\ne\n"}, Mode::Normal);
let window = cx.window;
let line_height =
cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache()));
window.simulate_resize(vec2f(1000., 8.0 * line_height - 1.0), &mut cx);
cx.set_state(
indoc!(
"ˇone
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
"
),
Mode::Normal,
);
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 0.))
@@ -112,5 +140,33 @@ mod test {
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 2.))
});
// does not select in normal mode
cx.simulate_keystrokes(["g", "g"]);
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 0.))
});
cx.simulate_keystrokes(["ctrl-d"]);
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 2.0));
assert_eq!(
editor.selections.newest(cx).range(),
Point::new(5, 0)..Point::new(5, 0)
)
});
// does select in visual mode
cx.simulate_keystrokes(["g", "g"]);
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 0.))
});
cx.simulate_keystrokes(["v", "ctrl-d"]);
cx.update_editor(|editor, cx| {
assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 2.0));
assert_eq!(
editor.selections.newest(cx).range(),
Point::new(0, 0)..Point::new(5, 1)
)
});
}
}

View File

@@ -3,7 +3,7 @@ authors = ["Nathan Sobo <nathansobo@gmail.com>"]
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.102.0"
version = "0.102.1"
publish = false
[lib]

View File

@@ -1 +1 @@
dev
stable