Compare commits
14 Commits
windows/ke
...
v0.138.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1ac769190 | ||
|
|
45dbb8964e | ||
|
|
62e8c705e6 | ||
|
|
832d339fa5 | ||
|
|
69cafdfb0d | ||
|
|
836dd012b7 | ||
|
|
0bd42365f6 | ||
|
|
9af6ec4897 | ||
|
|
4012751f7f | ||
|
|
dc1f107f71 | ||
|
|
a9bed95180 | ||
|
|
427b73c114 | ||
|
|
5a2297c2a3 | ||
|
|
1c7ee8998c |
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
})?;
|
||||
|
||||
@@ -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>) {
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
}),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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| {
|
||||
|
||||
@@ -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>"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
dev
|
||||
stable
|
||||
Reference in New Issue
Block a user