Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linux/changelog.d/4120.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dragging the results up no longer hides the query: the editor keeps a few lines.
47 changes: 47 additions & 0 deletions linux/crates/app/src/ui/editor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3317,3 +3317,50 @@ mod result_edits {
assert_eq!(tracker.pending_count(), 0);
}
}

#[gtk4::test]
fn the_divider_keeps_the_editor_in_view() {
let harness = editor_with(Replies::default(), "SELECT 1");
let window = crate::test_support::OwnedWindow::presented(
gtk4::Window::builder()
.default_width(800)
.default_height(600)
.child(&harness.editor)
.build(),
);
let paned = crate::test_support::descendants(&harness.editor)
.into_iter()
.find_map(|widget| widget.downcast::<gtk4::Paned>().ok())
.expect("the divider between the query and its results");
let editor = paned.start_child().expect("the editor pane");
let results = paned.end_child().expect("the results pane");
wait_until(WAIT, || paned.height() > 0).expect("the editor is allocated");

for text in ["SELECT 1".to_owned(), "SELECT 1;\n".repeat(300)] {
harness.editor.buffer().set_text(&text);
paned.set_position(0);
wait_until(WAIT, || paned.position() > 0).expect("the divider stops above the editor minimum");
let minimum = editor.measure(gtk4::Orientation::Vertical, paned.width()).0;
assert!(minimum >= 120);
assert!(editor.height() >= minimum);
assert!(harness.editor.imp().source_view.height() >= 120);

let bottom = paned.height();
paned.set_position(bottom);
wait_until(WAIT, || paned.position() < bottom).expect("the results retain their minimum");
assert!(results.height() >= results.measure(gtk4::Orientation::Vertical, paned.width()).0);
assert!(editor.height() >= minimum);

let middle = paned.height() / 2;
paned.set_position(middle);
wait_until(WAIT, || editor.height() > minimum && results.height() > 0)
.expect("the divider can still move between its limits");
}

window.set_default_size(800, 400);
wait_until(WAIT, || window.height() < 600).expect("the window becomes shorter");
paned.set_position(0);
wait_until(WAIT, || paned.position() > 0).expect("a short window keeps the editor visible");
assert!(harness.editor.imp().source_view.height() >= 120);
assert!(results.height() > 0);
}
5 changes: 4 additions & 1 deletion linux/data/resources/ui/sql-editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,16 @@
<property name="position">280</property>
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<!-- GtkPaned otherwise allows the query to disappear below
the scroller's minimum when the results are dragged up. -->
<property name="shrink-start-child">false</property>
<property name="shrink-end-child">false</property>
<property name="start-child">
<object class="AdwToolbarView" id="text_pane">
<property name="reveal-bottom-bars">false</property>
<property name="content">
<object class="GtkScrolledWindow">
<property name="min-content-height">200</property>
<property name="min-content-height">120</property>
<property name="child">
<object class="TableProEditorView" id="source_view">
<property name="show-line-numbers">true</property>
Expand Down
Loading