Compare commits

...

8 Commits

Author SHA1 Message Date
Joseph T Lyons
0bd42365f6 zed 0.138.3 2024-05-31 11:45:53 -04:00
gcp-cherry-pick-bot[bot]
9af6ec4897 indent guides: Use primary buffer language to determine tab size (cherry-pick #12506) (#12520)
Cherry-picked indent guides: Use primary buffer language to determine
tab size (#12506)

When indent guides were still WIP, I thought it might be a good idea to
detect the tab size for every line individually, so we can handle files
with mixed indentations. However, while optimizing the performance of
indent guides I found that getting the language at a given anchor was
pretty expensive, therefore I only resolved the language for the first
visible row. However, this could lead to some weird flickering, where
the indent guides would use different tab sizes depending on the first
visible row (see #12492). This can be fixed by just using the primary
buffer language size.

So as of right now indent guides cannot handle files with mixed
indentations. Im not sure if anyone actually does/expects this, but one
use case I could imagine is something like this:
User x has a svelte file, where the tab size is set to `4`. However the
svelte code uses typescript inside a script tag, which User x wants to
use a tab size of `2`. The approach used here would not work for this,
but then again I think our formatter does not even support something
like this. Im probably overcomplicating things, so let's stick with the
simple solution for now.

Release Notes:

- Fixed an issue where indent guides would use an incorrect tab size
([#12492](https://github.com/zed-industries/zed/issues/12492)).

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-05-31 10:12:14 +02:00
Kirill Bulatov
4012751f7f One less unwrap (#12448)
Fixes
https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1717011343884699

Release Notes:

- N/A
2024-05-30 23:35:20 +03:00
Nathan Sobo
dc1f107f71 zed 0.138.2 2024-05-29 16:56:04 -06:00
Nathan Sobo
a9bed95180 Make prompt library icon in context panel staff-only for now (#12457)
This is still pretty raw, so I'd like to hold off on shipping it to all
users.

Release Notes:

- Hide the prompt library for non-staff until it is in a more complete
state.
2024-05-29 16:54:44 -06:00
Max Brunsfeld
427b73c114 zed 0.138.1 2024-05-29 11:39:54 -07:00
Bennet Bo Fenner
5a2297c2a3 Fix deleted hunk offset when zooming (#12442)
Release Notes:

- Fixed an issue where expanded hunks could be rendered at the wrong
position when zooming
- Fixed an issue where expanded hunks could be rendered at the wrong
position when toggling git blame
([#11941](https://github.com/zed-industries/zed/issues/11941))
2024-05-29 11:13:07 -07:00
Joseph T. Lyons
1c7ee8998c v0.138.x preview 2024-05-29 12:15:00 -04:00
10 changed files with 68 additions and 49 deletions

3
Cargo.lock generated
View File

@@ -346,6 +346,7 @@ dependencies = [
"ctor",
"editor",
"env_logger",
"feature_flags",
"file_icons",
"fs",
"futures 0.3.28",
@@ -13046,7 +13047,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.138.0"
version = "0.138.3"
dependencies = [
"activity_indicator",
"anyhow",

View File

@@ -22,6 +22,7 @@ client.workspace = true
collections.workspace = true
command_palette_hooks.workspace = true
editor.workspace = true
feature_flags.workspace = true
file_icons.workspace = true
fs.workspace = true
futures.workspace = true

View File

@@ -28,6 +28,7 @@ use editor::{
ToOffset as _, ToPoint,
};
use editor::{display_map::FlapId, FoldPlaceholder};
use feature_flags::{FeatureFlag, FeatureFlagAppExt, FeatureFlagViewExt};
use file_icons::FileIcons;
use fs::Fs;
use futures::future::Shared;
@@ -127,6 +128,12 @@ struct ActiveConversationEditor {
_subscriptions: Vec<Subscription>,
}
struct PromptLibraryFeatureFlag;
impl FeatureFlag for PromptLibraryFeatureFlag {
const NAME: &'static str = "prompt-library";
}
impl AssistantPanel {
const INLINE_PROMPT_HISTORY_MAX_LEN: usize = 20;
@@ -152,6 +159,9 @@ impl AssistantPanel {
let workspace_handle = workspace.clone();
workspace.update(&mut cx, |workspace, cx| {
cx.new_view::<Self>(|cx| {
cx.observe_flag::<PromptLibraryFeatureFlag, _>(|_, _, cx| cx.notify())
.detach();
const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100);
let _watch_saved_conversations = cx.spawn(move |this, mut cx| async move {
let mut events = fs
@@ -1178,38 +1188,38 @@ impl AssistantPanel {
}
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let header =
TabBar::new("assistant_header")
.start_child(h_flex().gap_1().child(self.render_popover_button(cx)))
.children(self.active_conversation_editor().map(|editor| {
h_flex()
.h(rems(Tab::CONTAINER_HEIGHT_IN_REMS))
.flex_1()
.px_2()
.child(Label::new(editor.read(cx).title(cx)).into_element())
}))
.end_child(
h_flex()
.gap_2()
.when_some(self.active_conversation_editor(), |this, editor| {
let conversation = editor.read(cx).conversation.clone();
this.child(
h_flex()
.gap_1()
.child(self.render_model(&conversation, cx))
.children(self.render_remaining_tokens(&conversation, cx)),
)
.child(
ui::Divider::vertical()
.inset()
.color(ui::DividerColor::Border),
)
})
.child(
let header = TabBar::new("assistant_header")
.start_child(h_flex().gap_1().child(self.render_popover_button(cx)))
.children(self.active_conversation_editor().map(|editor| {
h_flex()
.h(rems(Tab::CONTAINER_HEIGHT_IN_REMS))
.flex_1()
.px_2()
.child(Label::new(editor.read(cx).title(cx)).into_element())
}))
.end_child(
h_flex()
.gap_2()
.when_some(self.active_conversation_editor(), |this, editor| {
let conversation = editor.read(cx).conversation.clone();
this.child(
h_flex()
.gap_1()
.child(self.render_inject_context_menu(cx))
.child(
.child(self.render_model(&conversation, cx))
.children(self.render_remaining_tokens(&conversation, cx)),
)
.child(
ui::Divider::vertical()
.inset()
.color(ui::DividerColor::Border),
)
})
.child(
h_flex()
.gap_1()
.child(self.render_inject_context_menu(cx))
.children(
cx.has_flag::<PromptLibraryFeatureFlag>().then_some(
IconButton::new("show_prompt_manager", IconName::Library)
.icon_size(IconSize::Small)
.on_click(cx.listener(|this, _event, cx| {
@@ -1217,8 +1227,9 @@ impl AssistantPanel {
}))
.tooltip(|cx| Tooltip::text("Prompt Library…", cx)),
),
),
);
),
),
);
let contents = if self.active_conversation_editor().is_some() {
let mut registrar = DivRegistrar::new(

View File

@@ -192,10 +192,13 @@ impl UserStore {
cx.update(|cx| {
if let Some(info) = info {
cx.update_flags(info.staff, info.flags);
let disable_staff = std::env::var("ZED_DISABLE_STAFF")
.map_or(false, |v| v != "" && v != "0");
let staff = info.staff && !disable_staff;
cx.update_flags(staff, info.flags);
client.telemetry.set_authenticated_user_info(
Some(info.metrics_id.clone()),
info.staff,
staff,
)
}
})?;

View File

@@ -309,17 +309,18 @@ impl Editor {
let deleted_hunk_color = deleted_hunk_color(cx);
let (editor_height, editor_with_deleted_text) =
editor_with_deleted_text(diff_base_buffer, deleted_hunk_color, hunk, cx);
let parent_gutter_offset = self.gutter_dimensions.width + self.gutter_dimensions.margin;
let editor_model = cx.model().clone();
let mut new_block_ids = self.insert_blocks(
Some(BlockProperties {
position: hunk.multi_buffer_range.start,
height: editor_height.max(deleted_text_height),
style: BlockStyle::Flex,
render: Box::new(move |_| {
render: Box::new(move |cx| {
let gutter_dimensions = editor_model.read(cx).gutter_dimensions;
div()
.bg(deleted_hunk_color)
.size_full()
.pl(parent_gutter_offset)
.pl(gutter_dimensions.width + gutter_dimensions.margin)
.child(editor_with_deleted_text.clone())
.into_any_element()
}),

View File

@@ -14,6 +14,12 @@ impl FeatureFlags {
impl Global for FeatureFlags {}
/// To create a feature flag, implement this trait on a trivial type and use it as
/// a generic parameter when called [`FeatureFlagAppExt::has_flag`].
///
/// Feature flags are always enabled for members of Zed staff. To disable this behavior
/// so you can test flags being disabled, set ZED_DISABLE_STAFF=1 in your environment,
/// which will force Zed to treat the current user as non-staff.
pub trait FeatureFlag {
const NAME: &'static str;
}

View File

@@ -3153,10 +3153,7 @@ impl BufferSnapshot {
range: Range<Anchor>,
cx: &AppContext,
) -> Vec<IndentGuide> {
fn tab_size_for_row(this: &BufferSnapshot, row: BufferRow, cx: &AppContext) -> u32 {
let language = this.language_at(Point::new(row, 0));
language_settings(language, None, cx).tab_size.get() as u32
}
let tab_size = language_settings(self.language(), None, cx).tab_size.get() as u32;
let start_row = range.start.to_point(self).row;
let end_row = range.end.to_point(self).row;
@@ -3167,9 +3164,6 @@ impl BufferSnapshot {
let mut result_vec = Vec::new();
let mut indent_stack = SmallVec::<[IndentGuide; 8]>::new();
// TODO: This should be calculated for every row but it is pretty expensive
let tab_size = tab_size_for_row(self, start_row, cx);
while let Some((first_row, mut line_indent)) = row_indents.next() {
let current_depth = indent_stack.len() as u32;

View File

@@ -89,8 +89,10 @@ impl Project {
path,
});
let is_terminal = spawn_task.is_none() && (working_directory.as_ref().is_none())
|| (working_directory.as_ref().unwrap().is_local());
let is_terminal = spawn_task.is_none()
&& working_directory
.as_ref()
.map_or(true, |work_dir| work_dir.is_local());
let settings = TerminalSettings::get(settings_location, cx);
let python_settings = settings.detect_venv.clone();
let (completion_tx, completion_rx) = bounded(1);

View File

@@ -2,7 +2,7 @@
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.138.0"
version = "0.138.3"
publish = false
license = "GPL-3.0-or-later"
authors = ["Zed Team <hi@zed.dev>"]

View File

@@ -1 +1 @@
dev
preview