fix(core): leave a maximized remembered column in its band on restore
2 files · +22 -1
M internal/core/cascade.go +2 -1
| @@ -539,7 +539,8 @@ func (w *Workspace) restoreBand() bool { | |||
| 539 | 539 | for k, nb := range nbs { | |
| 540 | 540 | adjacent := !slices.ContainsFunc(nbs[:k], func(n int) bool { return !ownOnly[n] }) | |
| 541 | 541 | i := slices.IndexFunc(bands[nb], func(c Column) bool { | |
| 542 | - | return c.Windows[0] == e[head] && (adjacent || c.ownBand) | |
| 542 | + | // A column the user maximized keeps its band. | |
| 543 | + | return c.Windows[0] == e[head] && !c.FullWidth && (adjacent || c.ownBand) | |
| 543 | 544 | }) | |
| 544 | 545 | if i < 0 { | |
| 545 | 546 | continue | |
| @@ -539,7 +539,8 @@ func (w *Workspace) restoreBand() bool { | |||||
| 539 | for k, nb := range nbs { | 539 | for k, nb := range nbs { | ||
| 540 | adjacent := !slices.ContainsFunc(nbs[:k], func(n int) bool { return !ownOnly[n] }) | 540 | adjacent := !slices.ContainsFunc(nbs[:k], func(n int) bool { return !ownOnly[n] }) | ||
| 541 | i := slices.IndexFunc(bands[nb], func(c Column) bool { | 541 | i := slices.IndexFunc(bands[nb], func(c Column) bool { | ||
| 542 | - | return c.Windows[0] == e[head] && (adjacent || c.ownBand) | 542 | + | // A column the user maximized keeps its band. |
| 543 | + | return c.Windows[0] == e[head] && !c.FullWidth && (adjacent || c.ownBand) | |||
| 543 | }) | 544 | }) | ||
| 544 | if i < 0 { | 545 | if i < 0 { | ||
| 545 | continue | 546 | continue | ||
M internal/core/cascade_fullscreen_band_test.go +20 -0
| @@ -386,6 +386,26 @@ func TestRestoreBandAcrossPromotedFloatBand(t *testing.T) { | |||
| 386 | 386 | } | |
| 387 | 387 | } | |
| 388 | 388 | ||
| 389 | + | // A remembered neighbor the user maximized since keeps its band; the | |
| 390 | + | // ordinary neighbors still come back. | |
| 391 | + | func TestRestoreBandLeavesMaximizedNeighbor(t *testing.T) { | |
| 392 | + | _, w := cascadeMovesCore(t, 3, 3, false) | |
| 393 | + | w.FocusID(1) | |
| 394 | + | w.ToggleFullWidth() | |
| 395 | + | wantBands(t, w, []WindowID{1}, []WindowID{2, 3}) | |
| 396 | + | w.FocusID(2) | |
| 397 | + | w.ToggleFullscreen() | |
| 398 | + | w.ToggleFullscreen() | |
| 399 | + | w.ToggleFullWidth() | |
| 400 | + | wantBands(t, w, []WindowID{1}, []WindowID{3}, []WindowID{2}) | |
| 401 | + | w.FocusID(1) | |
| 402 | + | w.ToggleFullWidth() | |
| 403 | + | wantBands(t, w, []WindowID{1, 3}, []WindowID{2}) | |
| 404 | + | if c := w.columnOf(2); c < 0 || !w.Columns[c].FullWidth { | |
| 405 | + | t.Fatal("column 2 lost its maximization") | |
| 406 | + | } | |
| 407 | + | } | |
| 408 | + | ||
| 389 | 409 | func TestPromotedFullscreenFloatMovesToNeighborMonitor(t *testing.T) { | |
| 390 | 410 | for _, tc := range []struct { | |
| 391 | 411 | a Action | |
| @@ -386,6 +386,26 @@ func TestRestoreBandAcrossPromotedFloatBand(t *testing.T) { | |||||
| 386 | } | 386 | } | ||
| 387 | } | 387 | } | ||
| 388 | 388 | ||||
| 389 | + | // A remembered neighbor the user maximized since keeps its band; the | |||
| 390 | + | // ordinary neighbors still come back. | |||
| 391 | + | func TestRestoreBandLeavesMaximizedNeighbor(t *testing.T) { | |||
| 392 | + | _, w := cascadeMovesCore(t, 3, 3, false) | |||
| 393 | + | w.FocusID(1) | |||
| 394 | + | w.ToggleFullWidth() | |||
| 395 | + | wantBands(t, w, []WindowID{1}, []WindowID{2, 3}) | |||
| 396 | + | w.FocusID(2) | |||
| 397 | + | w.ToggleFullscreen() | |||
| 398 | + | w.ToggleFullscreen() | |||
| 399 | + | w.ToggleFullWidth() | |||
| 400 | + | wantBands(t, w, []WindowID{1}, []WindowID{3}, []WindowID{2}) | |||
| 401 | + | w.FocusID(1) | |||
| 402 | + | w.ToggleFullWidth() | |||
| 403 | + | wantBands(t, w, []WindowID{1, 3}, []WindowID{2}) | |||
| 404 | + | if c := w.columnOf(2); c < 0 || !w.Columns[c].FullWidth { | |||
| 405 | + | t.Fatal("column 2 lost its maximization") | |||
| 406 | + | } | |||
| 407 | + | } | |||
| 408 | + | ||||
| 389 | func TestPromotedFullscreenFloatMovesToNeighborMonitor(t *testing.T) { | 409 | func TestPromotedFullscreenFloatMovesToNeighborMonitor(t *testing.T) { | ||
| 390 | for _, tc := range []struct { | 410 | for _, tc := range []struct { | ||
| 391 | a Action | 411 | a Action | ||