Add test for pane: toggle pin tab
(#31906)
Also adds the optimization to not move a tab being pinned when its destination index is the same as its index. Release Notes: - N/A
This commit is contained in:
parent
ebed567adb
commit
1ed4647203
1 changed files with 35 additions and 7 deletions
|
@ -2087,6 +2087,9 @@ impl Pane {
|
||||||
|
|
||||||
let id = self.item_for_index(ix)?.item_id();
|
let id = self.item_for_index(ix)?.item_id();
|
||||||
|
|
||||||
|
if ix == destination_index {
|
||||||
|
cx.notify()
|
||||||
|
} else {
|
||||||
self.workspace
|
self.workspace
|
||||||
.update(cx, |_, cx| {
|
.update(cx, |_, cx| {
|
||||||
cx.defer_in(window, move |_, window, cx| {
|
cx.defer_in(window, move |_, window, cx| {
|
||||||
|
@ -2094,6 +2097,7 @@ impl Pane {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
}
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
});
|
});
|
||||||
|
@ -4085,6 +4089,30 @@ mod tests {
|
||||||
assert_item_labels(&pane, ["A^", "B^", "C^", "G*^"], cx);
|
assert_item_labels(&pane, ["A^", "B^", "C^", "G*^"], cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_toggle_pin_tab(cx: &mut TestAppContext) {
|
||||||
|
init_test(cx);
|
||||||
|
let fs = FakeFs::new(cx.executor());
|
||||||
|
|
||||||
|
let project = Project::test(fs, None, cx).await;
|
||||||
|
let (workspace, cx) =
|
||||||
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
|
set_labeled_items(&pane, ["A", "B*", "C"], cx);
|
||||||
|
assert_item_labels(&pane, ["A", "B*", "C"], cx);
|
||||||
|
|
||||||
|
pane.update_in(cx, |pane, window, cx| {
|
||||||
|
pane.toggle_pin_tab(&TogglePinTab, window, cx);
|
||||||
|
});
|
||||||
|
assert_item_labels(&pane, ["B*!", "A", "C"], cx);
|
||||||
|
|
||||||
|
pane.update_in(cx, |pane, window, cx| {
|
||||||
|
pane.toggle_pin_tab(&TogglePinTab, window, cx);
|
||||||
|
});
|
||||||
|
assert_item_labels(&pane, ["B*", "A", "C"], cx);
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_add_item_with_new_item(cx: &mut TestAppContext) {
|
async fn test_add_item_with_new_item(cx: &mut TestAppContext) {
|
||||||
init_test(cx);
|
init_test(cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue