Skip to content

Commit cde6c2f

Browse files
MrSubidubiJosephTLyons
authored andcommitted
agent: Do not render unnecessary lines in edit file tool card (#29766)
This PR prevents any unnecessary lines from being rendered in the edit file tool card in the case of small diffs. I think this (hopefully) addresses the last remaining task from #29448. | `main` | This PR | | --- | --- | | <img width="634" alt="main" src="https://github.com/user-attachments/assets/7c06394e-957a-4d36-a484-5974687041e9" /> | <img width="634" alt="PR" src="https://github.com/user-attachments/assets/84206d5a-a93a-4a42-99ca-7cdebb0d91bb" /> | (The last empty line in the second image is an empty line present in the file itself) --- n the second commit I also preemtively disabled vertical overscrolling for full mode editors which are sized by content. This is basically the same fix as in #28471. Strictly speaking, this is not needed for the fix here, but I thought it might be nice to have for the future to prevent any issues from occuring due to overscroll. Release Notes: - agent: Improved rendering of small diffs for the edit file tool card.
1 parent 40b51c2 commit cde6c2f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

crates/assistant_tools/src/edit_file_tool.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,10 @@ impl ToolCard for EditFileToolCard {
577577
card.child(
578578
v_flex()
579579
.relative()
580-
.map(|editor_container| {
581-
if self.full_height_expanded {
582-
editor_container.h_full()
583-
} else {
584-
editor_container
585-
.h(DEFAULT_COLLAPSED_LINES as f32 * editor_line_height)
586-
}
580+
.h_full()
581+
.when(!self.full_height_expanded, |editor_container| {
582+
editor_container
583+
.max_h(DEFAULT_COLLAPSED_LINES as f32 * editor_line_height)
587584
})
588585
.overflow_hidden()
589586
.border_t_1()

crates/editor/src/element.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6871,7 +6871,12 @@ impl Element for EditorElement {
68716871
// The max scroll position for the top of the window
68726872
let max_scroll_top = if matches!(
68736873
snapshot.mode,
6874-
EditorMode::AutoHeight { .. } | EditorMode::SingleLine { .. }
6874+
EditorMode::SingleLine { .. }
6875+
| EditorMode::AutoHeight { .. }
6876+
| EditorMode::Full {
6877+
sized_by_content: true,
6878+
..
6879+
}
68756880
) {
68766881
(max_row - height_in_lines + 1.).max(0.)
68776882
} else {

0 commit comments

Comments
 (0)