Skip to content

Commit

Permalink
Ensure project search actions are always aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-leal committed Nov 7, 2024
1 parent 083f063 commit 8c7eeb0
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 53 deletions.
1 change: 1 addition & 0 deletions assets/icons/file_search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions crates/assistant/src/slash_command/delta_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ impl SlashCommand for DeltaSlashCommand {
}
}

// // If no changes detected, add a message section
// if !changes_detected {
// output.sections.push(SlashCommandOutputSection {
// range: 0..0,
// icon: IconName::Info, // Use an appropriate icon
// label: Some("Info".into()),
// metadata: Some(serde_json::json!({"message": "No changes detected"})),
// });
// output.text.push_str("No changes detected\n");
// }

Ok(output.to_event_stream())
})
}
Expand Down
108 changes: 55 additions & 53 deletions crates/search/src/project_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ impl Render for ProjectSearchBar {
.child(
div()
.id("matches")
.ml_0p5()
.ml_1()
.child(
Label::new(match_text).color(if search.active_match_index.is_some() {
Color::Default
Expand All @@ -1765,68 +1765,69 @@ impl Render for ProjectSearchBar {
let search_line = h_flex()
.w_full()
.gap_1p5()
.pr_6()
.child(query_column)
.child(mode_column)
.child(matches_column);
.child(h_flex().min_w_40().child(mode_column).child(matches_column));

let replace_line = search.replace_enabled.then(|| {
let replace_column =
input_base_styles().child(self.render_text_input(&search.replacement_editor, cx));

let focus_handle = search.replacement_editor.read(cx).focus_handle(cx);

let replace_actions = h_flex().gap_1().when(search.replace_enabled, |this| {
this.child(
IconButton::new("project-search-replace-next", IconName::ReplaceNext)
.shape(IconButtonShape::Square)
.on_click(cx.listener(|this, _, cx| {
if let Some(search) = this.active_project_search.as_ref() {
search.update(cx, |this, cx| {
this.replace_next(&ReplaceNext, cx);
})
}
}))
.tooltip({
let focus_handle = focus_handle.clone();
move |cx| {
Tooltip::for_action_in(
"Replace Next Match",
&ReplaceNext,
&focus_handle,
cx,
)
}
}),
)
.child(
IconButton::new("project-search-replace-all", IconName::ReplaceAll)
.shape(IconButtonShape::Square)
.on_click(cx.listener(|this, _, cx| {
if let Some(search) = this.active_project_search.as_ref() {
search.update(cx, |this, cx| {
this.replace_all(&ReplaceAll, cx);
})
}
}))
.tooltip({
let focus_handle = focus_handle.clone();
move |cx| {
Tooltip::for_action_in(
"Replace All Matches",
&ReplaceAll,
&focus_handle,
cx,
)
}
}),
)
});
let replace_actions =
h_flex()
.min_w_40()
.gap_1()
.when(search.replace_enabled, |this| {
this.child(
IconButton::new("project-search-replace-next", IconName::ReplaceNext)
.shape(IconButtonShape::Square)
.on_click(cx.listener(|this, _, cx| {
if let Some(search) = this.active_project_search.as_ref() {
search.update(cx, |this, cx| {
this.replace_next(&ReplaceNext, cx);
})
}
}))
.tooltip({
let focus_handle = focus_handle.clone();
move |cx| {
Tooltip::for_action_in(
"Replace Next Match",
&ReplaceNext,
&focus_handle,
cx,
)
}
}),
)
.child(
IconButton::new("project-search-replace-all", IconName::ReplaceAll)
.shape(IconButtonShape::Square)
.on_click(cx.listener(|this, _, cx| {
if let Some(search) = this.active_project_search.as_ref() {
search.update(cx, |this, cx| {
this.replace_all(&ReplaceAll, cx);
})
}
}))
.tooltip({
let focus_handle = focus_handle.clone();
move |cx| {
Tooltip::for_action_in(
"Replace All Matches",
&ReplaceAll,
&focus_handle,
cx,
)
}
}),
)
});

h_flex()
.w_full()
.gap_1p5()
.pr_24()
.child(replace_column)
.child(replace_actions)
});
Expand All @@ -1835,7 +1836,6 @@ impl Render for ProjectSearchBar {
h_flex()
.w_full()
.gap_1p5()
.pr_24()
.child(
input_base_styles()
.on_action(
Expand All @@ -1858,10 +1858,12 @@ impl Render for ProjectSearchBar {
)
.child(
h_flex()
.min_w_40()
.gap_1()
.child(
IconButton::new("project-search-opened-only", IconName::FileDoc)
IconButton::new("project-search-opened-only", IconName::FileSearch)
.shape(IconButtonShape::Square)
.icon_size(IconSize::XSmall)
.selected(self.is_opened_only_enabled(cx))
.tooltip(|cx| Tooltip::text("Only Search Open Files", cx))
.on_click(cx.listener(|this, _, cx| {
Expand Down
1 change: 1 addition & 0 deletions crates/ui/src/components/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub enum IconName {
FileGit,
FileLock,
FileRust,
FileSearch,
FileText,
FileToml,
FileTree,
Expand Down

0 comments on commit 8c7eeb0

Please sign in to comment.