Compare commits

...

14 Commits

Author SHA1 Message Date
Zed Bot
e1ac769190 Bump to 0.138.5 for @osiewicz 2024-06-07 01:28:17 -07:00
Joseph T Lyons
45dbb8964e v0.138.x stable 2024-06-05 12:23:39 -04:00
Kirill Bulatov
62e8c705e6 Do not occlude terminal pane by terminal element (#12677)
Release Notes:

- Fixed file drag and drop not working for terminal

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
2024-06-05 13:43:43 +03:00
Bennet Bo Fenner
832d339fa5 zed 0.138.4 2024-06-03 17:13:34 +02:00
gcp-cherry-pick-bot[bot]
69cafdfb0d Disable indent guides for single line editors (cherry-pick #12584) (#12595)
Cherry-picked Disable indent guides for single line editors (#12584)

This PR disables indent guides by default for single line editors. Right
now indent guides show up in the project search editor (which is only a
single line)

<img width="715" alt="image"

src="https://github.com/zed-industries/zed/assets/53836821/0b61da71-6f64-424d-9612-6a34eac4686a">


Release Notes:

- Fixed an issue where indent guides would show up in a single line
editor (e.g. project search, buffer search)

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-06-03 09:51:43 +02:00
gcp-cherry-pick-bot[bot]
836dd012b7 indent guides: Respect language specific settings in multibuffers (cherry-pick #12528) (#12594)
Cherry-picked indent guides: Respect language specific settings in
multibuffers (#12528)

Indent guides can be configured per language, meaning that in a multi
buffer we can get excerpts where indent guides should be
disabled/enabled/styled differently than other excerpts.

Imagine the following scenario, i have indent guides disabled in my
settings, but want to enable them for JS and Python. I also want to use
a different line width for python files. Something like this is now
supported:

<img width="445" alt="image"

src="https://github.com/zed-industries/zed/assets/53836821/0c91411c-145c-4210-a883-4c469d5cb828">

And the relevant settings for the example above:
```json
"indent_guides": {
  "enabled": false
},
"languages": {
  "JavaScript": {
    "indent_guides": {
      "enabled": true
    }
  },
  "Python": {
    "indent_guides": {
      "enabled": true,
      "line_width": 5
    }
  }
}
```



Release Notes:

- Respect language specific settings when showing indent guides in a
multibuffer
- Fixes an issue where indent guide specific settings were not
recognized when specified in local settings

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-06-03 09:29:01 +02:00
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
16 changed files with 186 additions and 150 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.5"
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

@@ -1697,6 +1697,12 @@ impl Editor {
cx.on_focus(&focus_handle, Self::handle_focus).detach();
cx.on_blur(&focus_handle, Self::handle_blur).detach();
let show_indent_guides = if mode == EditorMode::SingleLine {
Some(false)
} else {
None
};
let mut this = Self {
focus_handle,
buffer: buffer.clone(),
@@ -1726,7 +1732,7 @@ impl Editor {
show_git_diff_gutter: None,
show_code_actions: None,
show_wrap_guides: None,
show_indent_guides: None,
show_indent_guides,
placeholder_text: None,
highlight_order: 0,
highlighted_rows: HashMap::default(),
@@ -9770,19 +9776,19 @@ impl Editor {
}
pub fn toggle_indent_guides(&mut self, _: &ToggleIndentGuides, cx: &mut ViewContext<Self>) {
let currently_enabled = self.should_show_indent_guides(cx);
self.show_indent_guides = Some(!currently_enabled);
cx.notify();
}
fn should_show_indent_guides(&self, cx: &mut ViewContext<Self>) -> bool {
self.show_indent_guides.unwrap_or_else(|| {
let currently_enabled = self.should_show_indent_guides().unwrap_or_else(|| {
self.buffer
.read(cx)
.settings_at(0, cx)
.indent_guides
.enabled
})
});
self.show_indent_guides = Some(!currently_enabled);
cx.notify();
}
fn should_show_indent_guides(&self) -> Option<bool> {
self.show_indent_guides
}
pub fn toggle_line_numbers(&mut self, _: &ToggleLineNumbers, cx: &mut ViewContext<Self>) {

View File

@@ -20,6 +20,7 @@ use language::{
FakeLspAdapter, IndentGuide, LanguageConfig, LanguageConfigOverride, LanguageMatcher, Override,
Point,
};
use language_settings::IndentGuideSettings;
use multi_buffer::MultiBufferIndentGuide;
use parking_lot::Mutex;
use project::project_settings::{LspSettings, ProjectSettings};
@@ -11505,6 +11506,7 @@ fn assert_indent_guides(
let snapshot = editor.snapshot(cx).display_snapshot;
let mut indent_guides: Vec<_> = crate::indent_guides::indent_guides_in_range(
MultiBufferRow(range.start)..MultiBufferRow(range.end),
true,
&snapshot,
cx,
);
@@ -11543,6 +11545,21 @@ fn assert_indent_guides(
assert_eq!(indent_guides, expected, "Indent guides do not match");
}
fn indent_guide(buffer_id: BufferId, start_row: u32, end_row: u32, depth: u32) -> IndentGuide {
IndentGuide {
buffer_id,
start_row,
end_row,
depth,
tab_size: 4,
settings: IndentGuideSettings {
enabled: true,
line_width: 1,
..Default::default()
},
}
}
#[gpui::test]
async fn test_indent_guide_single_line(cx: &mut gpui::TestAppContext) {
let (buffer_id, mut cx) = setup_indent_guides_editor(
@@ -11555,12 +11572,7 @@ async fn test_indent_guide_single_line(cx: &mut gpui::TestAppContext) {
)
.await;
assert_indent_guides(
0..3,
vec![IndentGuide::new(buffer_id, 1, 1, 0, 4)],
None,
&mut cx,
);
assert_indent_guides(0..3, vec![indent_guide(buffer_id, 1, 1, 0)], None, &mut cx);
}
#[gpui::test]
@@ -11576,12 +11588,7 @@ async fn test_indent_guide_simple_block(cx: &mut gpui::TestAppContext) {
)
.await;
assert_indent_guides(
0..4,
vec![IndentGuide::new(buffer_id, 1, 2, 0, 4)],
None,
&mut cx,
);
assert_indent_guides(0..4, vec![indent_guide(buffer_id, 1, 2, 0)], None, &mut cx);
}
#[gpui::test]
@@ -11604,9 +11611,9 @@ async fn test_indent_guide_nested(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..8,
vec![
IndentGuide::new(buffer_id, 1, 6, 0, 4),
IndentGuide::new(buffer_id, 3, 3, 1, 4),
IndentGuide::new(buffer_id, 5, 5, 1, 4),
indent_guide(buffer_id, 1, 6, 0),
indent_guide(buffer_id, 3, 3, 1),
indent_guide(buffer_id, 5, 5, 1),
],
None,
&mut cx,
@@ -11630,8 +11637,8 @@ async fn test_indent_guide_tab(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..5,
vec![
IndentGuide::new(buffer_id, 1, 3, 0, 4),
IndentGuide::new(buffer_id, 2, 2, 1, 4),
indent_guide(buffer_id, 1, 3, 0),
indent_guide(buffer_id, 2, 2, 1),
],
None,
&mut cx,
@@ -11652,12 +11659,7 @@ async fn test_indent_guide_continues_on_empty_line(cx: &mut gpui::TestAppContext
)
.await;
assert_indent_guides(
0..5,
vec![IndentGuide::new(buffer_id, 1, 3, 0, 4)],
None,
&mut cx,
);
assert_indent_guides(0..5, vec![indent_guide(buffer_id, 1, 3, 0)], None, &mut cx);
}
#[gpui::test]
@@ -11683,9 +11685,9 @@ async fn test_indent_guide_complex(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..11,
vec![
IndentGuide::new(buffer_id, 1, 9, 0, 4),
IndentGuide::new(buffer_id, 6, 6, 1, 4),
IndentGuide::new(buffer_id, 8, 8, 1, 4),
indent_guide(buffer_id, 1, 9, 0),
indent_guide(buffer_id, 6, 6, 1),
indent_guide(buffer_id, 8, 8, 1),
],
None,
&mut cx,
@@ -11715,9 +11717,9 @@ async fn test_indent_guide_starts_off_screen(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
1..11,
vec![
IndentGuide::new(buffer_id, 1, 9, 0, 4),
IndentGuide::new(buffer_id, 6, 6, 1, 4),
IndentGuide::new(buffer_id, 8, 8, 1, 4),
indent_guide(buffer_id, 1, 9, 0),
indent_guide(buffer_id, 6, 6, 1),
indent_guide(buffer_id, 8, 8, 1),
],
None,
&mut cx,
@@ -11747,9 +11749,9 @@ async fn test_indent_guide_ends_off_screen(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
1..10,
vec![
IndentGuide::new(buffer_id, 1, 9, 0, 4),
IndentGuide::new(buffer_id, 6, 6, 1, 4),
IndentGuide::new(buffer_id, 8, 8, 1, 4),
indent_guide(buffer_id, 1, 9, 0),
indent_guide(buffer_id, 6, 6, 1),
indent_guide(buffer_id, 8, 8, 1),
],
None,
&mut cx,
@@ -11775,9 +11777,9 @@ async fn test_indent_guide_without_brackets(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
1..10,
vec![
IndentGuide::new(buffer_id, 1, 4, 0, 4),
IndentGuide::new(buffer_id, 2, 3, 1, 4),
IndentGuide::new(buffer_id, 3, 3, 2, 4),
indent_guide(buffer_id, 1, 4, 0),
indent_guide(buffer_id, 2, 3, 1),
indent_guide(buffer_id, 3, 3, 2),
],
None,
&mut cx,
@@ -11802,8 +11804,8 @@ async fn test_indent_guide_ends_before_empty_line(cx: &mut gpui::TestAppContext)
assert_indent_guides(
0..6,
vec![
IndentGuide::new(buffer_id, 1, 2, 0, 4),
IndentGuide::new(buffer_id, 2, 2, 1, 4),
indent_guide(buffer_id, 1, 2, 0),
indent_guide(buffer_id, 2, 2, 1),
],
None,
&mut cx,
@@ -11825,12 +11827,7 @@ async fn test_indent_guide_continuing_off_screen(cx: &mut gpui::TestAppContext)
)
.await;
assert_indent_guides(
0..1,
vec![IndentGuide::new(buffer_id, 1, 1, 0, 4)],
None,
&mut cx,
);
assert_indent_guides(0..1, vec![indent_guide(buffer_id, 1, 1, 0)], None, &mut cx);
}
#[gpui::test]
@@ -11852,8 +11849,8 @@ async fn test_indent_guide_tabs(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..6,
vec![
IndentGuide::new(buffer_id, 1, 6, 0, 4),
IndentGuide::new(buffer_id, 3, 4, 1, 4),
indent_guide(buffer_id, 1, 6, 0),
indent_guide(buffer_id, 3, 4, 1),
],
None,
&mut cx,
@@ -11880,7 +11877,7 @@ async fn test_active_indent_guide_single_line(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..3,
vec![IndentGuide::new(buffer_id, 1, 1, 0, 4)],
vec![indent_guide(buffer_id, 1, 1, 0)],
Some(vec![0]),
&mut cx,
);
@@ -11909,8 +11906,8 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut gpui::TestAppC
assert_indent_guides(
0..4,
vec![
IndentGuide::new(buffer_id, 1, 3, 0, 4),
IndentGuide::new(buffer_id, 2, 2, 1, 4),
indent_guide(buffer_id, 1, 3, 0),
indent_guide(buffer_id, 2, 2, 1),
],
Some(vec![1]),
&mut cx,
@@ -11925,8 +11922,8 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut gpui::TestAppC
assert_indent_guides(
0..4,
vec![
IndentGuide::new(buffer_id, 1, 3, 0, 4),
IndentGuide::new(buffer_id, 2, 2, 1, 4),
indent_guide(buffer_id, 1, 3, 0),
indent_guide(buffer_id, 2, 2, 1),
],
Some(vec![1]),
&mut cx,
@@ -11941,8 +11938,8 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut gpui::TestAppC
assert_indent_guides(
0..4,
vec![
IndentGuide::new(buffer_id, 1, 3, 0, 4),
IndentGuide::new(buffer_id, 2, 2, 1, 4),
indent_guide(buffer_id, 1, 3, 0),
indent_guide(buffer_id, 2, 2, 1),
],
Some(vec![0]),
&mut cx,
@@ -11971,7 +11968,7 @@ async fn test_active_indent_guide_empty_line(cx: &mut gpui::TestAppContext) {
assert_indent_guides(
0..5,
vec![IndentGuide::new(buffer_id, 1, 3, 0, 4)],
vec![indent_guide(buffer_id, 1, 3, 0)],
Some(vec![0]),
&mut cx,
);
@@ -11997,7 +11994,7 @@ async fn test_active_indent_guide_non_matching_indent(cx: &mut gpui::TestAppCont
assert_indent_guides(
0..3,
vec![IndentGuide::new(buffer_id, 1, 2, 0, 4)],
vec![indent_guide(buffer_id, 1, 2, 0)],
Some(vec![0]),
&mut cx,
);

View File

@@ -38,7 +38,7 @@ use gpui::{
};
use itertools::Itertools;
use language::language_settings::{
IndentGuideBackgroundColoring, IndentGuideColoring, ShowWhitespaceSetting,
IndentGuideBackgroundColoring, IndentGuideColoring, IndentGuideSettings, ShowWhitespaceSetting,
};
use lsp::DiagnosticSeverity;
use multi_buffer::{Anchor, MultiBufferPoint, MultiBufferRow};
@@ -1438,6 +1438,7 @@ impl EditorElement {
single_indent_width,
depth: indent_guide.depth,
active: active_indent_guide_indices.contains(&i),
settings: indent_guide.settings,
})
} else {
None
@@ -2730,14 +2731,6 @@ impl EditorElement {
return;
};
let settings = self
.editor
.read(cx)
.buffer()
.read(cx)
.settings_at(0, cx)
.indent_guides;
let faded_color = |color: Hsla, alpha: f32| {
let mut faded = color;
faded.a = alpha;
@@ -2746,6 +2739,7 @@ impl EditorElement {
for indent_guide in indent_guides {
let indent_accent_colors = cx.theme().accents().color_for_index(indent_guide.depth);
let settings = indent_guide.settings;
// TODO fixed for now, expose them through themes later
const INDENT_AWARE_ALPHA: f32 = 0.2;
@@ -2753,7 +2747,7 @@ impl EditorElement {
const INDENT_AWARE_BACKGROUND_ALPHA: f32 = 0.1;
const INDENT_AWARE_BACKGROUND_ACTIVE_ALPHA: f32 = 0.2;
let line_color = match (&settings.coloring, indent_guide.active) {
let line_color = match (settings.coloring, indent_guide.active) {
(IndentGuideColoring::Disabled, _) => None,
(IndentGuideColoring::Fixed, false) => {
Some(cx.theme().colors().editor_indent_guide)
@@ -2769,7 +2763,7 @@ impl EditorElement {
}
};
let background_color = match (&settings.background_coloring, indent_guide.active) {
let background_color = match (settings.background_coloring, indent_guide.active) {
(IndentGuideBackgroundColoring::Disabled, _) => None,
(IndentGuideBackgroundColoring::IndentAware, false) => Some(faded_color(
indent_accent_colors,
@@ -5286,6 +5280,7 @@ pub struct IndentGuideLayout {
single_indent_width: Pixels,
depth: u32,
active: bool,
settings: IndentGuideSettings,
}
pub struct CursorLayout {

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

@@ -2,7 +2,7 @@ use std::{ops::Range, time::Duration};
use collections::HashSet;
use gpui::{AppContext, Task};
use language::BufferRow;
use language::{language_settings::language_settings, BufferRow};
use multi_buffer::{MultiBufferIndentGuide, MultiBufferRow};
use text::{BufferId, LineIndent, Point};
use ui::ViewContext;
@@ -37,13 +37,26 @@ impl Editor {
snapshot: &DisplaySnapshot,
cx: &mut ViewContext<Editor>,
) -> Option<Vec<MultiBufferIndentGuide>> {
let enabled = self.should_show_indent_guides(cx);
let show_indent_guides = self.should_show_indent_guides().unwrap_or_else(|| {
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
language_settings(buffer.read(cx).language(), buffer.read(cx).file(), cx)
.indent_guides
.enabled
} else {
true
}
});
if enabled {
Some(indent_guides_in_range(visible_buffer_range, snapshot, cx))
} else {
None
if !show_indent_guides {
return None;
}
Some(indent_guides_in_range(
visible_buffer_range,
self.should_show_indent_guides() == Some(true),
snapshot,
cx,
))
}
pub fn find_active_indent_guide_indices(
@@ -77,9 +90,14 @@ impl Editor {
if state.should_refresh() {
state.cursor_row = cursor_row;
let snapshot = snapshot.clone();
state.dirty = false;
if indent_guides.is_empty() {
return None;
}
let snapshot = snapshot.clone();
let task = cx
.background_executor()
.spawn(resolve_indented_range(snapshot, cursor_row));
@@ -131,6 +149,7 @@ impl Editor {
pub fn indent_guides_in_range(
visible_buffer_range: Range<MultiBufferRow>,
ignore_disabled_for_language: bool,
snapshot: &DisplaySnapshot,
cx: &AppContext,
) -> Vec<MultiBufferIndentGuide> {
@@ -143,7 +162,7 @@ pub fn indent_guides_in_range(
snapshot
.buffer_snapshot
.indent_guides_in_range(start_anchor..end_anchor, cx)
.indent_guides_in_range(start_anchor..end_anchor, ignore_disabled_for_language, cx)
.into_iter()
.filter(|indent_guide| {
// Filter out indent guides that are inside a fold

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

@@ -6,7 +6,7 @@ pub use crate::{
};
use crate::{
diagnostic_set::{DiagnosticEntry, DiagnosticGroup},
language_settings::{language_settings, LanguageSettings},
language_settings::{language_settings, IndentGuideSettings, LanguageSettings},
markdown::parse_markdown,
outline::OutlineItem,
syntax_map::{
@@ -542,25 +542,10 @@ pub struct IndentGuide {
pub end_row: BufferRow,
pub depth: u32,
pub tab_size: u32,
pub settings: IndentGuideSettings,
}
impl IndentGuide {
pub fn new(
buffer_id: BufferId,
start_row: BufferRow,
end_row: BufferRow,
depth: u32,
tab_size: u32,
) -> Self {
Self {
buffer_id,
start_row,
end_row,
depth,
tab_size,
}
}
pub fn indent_level(&self) -> u32 {
self.depth * self.tab_size
}
@@ -3151,12 +3136,15 @@ impl BufferSnapshot {
pub fn indent_guides_in_range(
&self,
range: Range<Anchor>,
ignore_disabled_for_language: bool,
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 language_settings = language_settings(self.language(), self.file.as_ref(), cx);
let settings = language_settings.indent_guides;
if !ignore_disabled_for_language && !settings.enabled {
return Vec::new();
}
let tab_size = language_settings.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 +3155,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;
@@ -3240,6 +3225,7 @@ impl BufferSnapshot {
end_row: last_row,
depth: next_depth,
tab_size,
settings,
});
}
}

View File

@@ -3289,12 +3289,17 @@ impl MultiBufferSnapshot {
pub fn indent_guides_in_range(
&self,
range: Range<Anchor>,
ignore_disabled_for_language: bool,
cx: &AppContext,
) -> Vec<MultiBufferIndentGuide> {
// Fast path for singleton buffers, we can skip the conversion between offsets.
if let Some((_, _, snapshot)) = self.as_singleton() {
return snapshot
.indent_guides_in_range(range.start.text_anchor..range.end.text_anchor, cx)
.indent_guides_in_range(
range.start.text_anchor..range.end.text_anchor,
ignore_disabled_for_language,
cx,
)
.into_iter()
.map(|guide| MultiBufferIndentGuide {
multibuffer_row_range: MultiBufferRow(guide.start_row)
@@ -3314,7 +3319,11 @@ impl MultiBufferSnapshot {
excerpt
.buffer
.indent_guides_in_range(excerpt.range.context.clone(), cx)
.indent_guides_in_range(
excerpt.range.context.clone(),
ignore_disabled_for_language,
cx,
)
.into_iter()
.map(move |indent_guide| {
let start_row = excerpt_offset_row

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

@@ -553,7 +553,6 @@ impl Element for TerminalElement {
global_id: Option<&GlobalElementId>,
cx: &mut WindowContext,
) -> (LayoutId, Self::RequestLayoutState) {
self.interactivity.occlude_mouse();
let layout_id = self
.interactivity
.request_layout(global_id, cx, |mut style, cx| {

View File

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

View File

@@ -1 +1 @@
dev
stable