fix(core): clear foreign span stamps on columns added by addColumn
2 files · +17 -0
M internal/core/layout.go +2 -0
| @@ -548,6 +548,8 @@ func (w *Workspace) addWindow(id WindowID, cells int) { | |||
| 548 | 548 | // addColumn places a new column like a new window and focuses it. | |
| 549 | 549 | func (w *Workspace) addColumn(col Column) { | |
| 550 | 550 | at := 0 | |
| 551 | + | // Stamp identities belong to the issuing workspace and complete lane. | |
| 552 | + | col.Span, col.spanStamp = 0, 0 | |
| 551 | 553 | col.BandStart = false | |
| 552 | 554 | if w.policy().wraps { | |
| 553 | 555 | // After the focused band: it joins it when it has room, else it | |
| @@ -548,6 +548,8 @@ func (w *Workspace) addWindow(id WindowID, cells int) { | |||||
| 548 | // addColumn places a new column like a new window and focuses it. | 548 | // addColumn places a new column like a new window and focuses it. | ||
| 549 | func (w *Workspace) addColumn(col Column) { | 549 | func (w *Workspace) addColumn(col Column) { | ||
| 550 | at := 0 | 550 | at := 0 | ||
| 551 | + | // Stamp identities belong to the issuing workspace and complete lane. | |||
| 552 | + | col.Span, col.spanStamp = 0, 0 | |||
| 551 | col.BandStart = false | 553 | col.BandStart = false | ||
| 552 | if w.policy().wraps { | 554 | if w.policy().wraps { | ||
| 553 | // After the focused band: it joins it when it has room, else it | 555 | // After the focused band: it joins it when it has room, else it | ||
M internal/core/spans_test.go +15 -0
| @@ -186,3 +186,18 @@ func TestSpanLaneIdentity(t *testing.T) { | |||
| 186 | 186 | }) | |
| 187 | 187 | } | |
| 188 | 188 | } | |
| 189 | + | ||
| 190 | + | // A column arriving from another workspace carries that workspace's stamp, | |
| 191 | + | // which may collide with a stamp issued here. | |
| 192 | + | func TestSpansForeignStampCleared(t *testing.T) { | |
| 193 | + | w := spanWorkspace(OverflowScroll, 2) | |
| 194 | + | stampSpans(w, 0, 1) | |
| 195 | + | stamp := w.spanSeq | |
| 196 | + | w.receive(Column{Windows: []WindowID{9}, Span: 3000, spanStamp: stamp}, -1) | |
| 197 | + | w.dropStaleSpans() | |
| 198 | + | for _, col := range w.Columns { | |
| 199 | + | if col.Span != 0 || col.spanStamp != 0 { | |
| 200 | + | t.Fatal("foreign stamp joined the lane", w.Columns) | |
| 201 | + | } | |
| 202 | + | } | |
| 203 | + | } | |
| @@ -186,3 +186,18 @@ func TestSpanLaneIdentity(t *testing.T) { | |||||
| 186 | }) | 186 | }) | ||
| 187 | } | 187 | } | ||
| 188 | } | 188 | } | ||
| 189 | + | ||||
| 190 | + | // A column arriving from another workspace carries that workspace's stamp, | |||
| 191 | + | // which may collide with a stamp issued here. | |||
| 192 | + | func TestSpansForeignStampCleared(t *testing.T) { | |||
| 193 | + | w := spanWorkspace(OverflowScroll, 2) | |||
| 194 | + | stampSpans(w, 0, 1) | |||
| 195 | + | stamp := w.spanSeq | |||
| 196 | + | w.receive(Column{Windows: []WindowID{9}, Span: 3000, spanStamp: stamp}, -1) | |||
| 197 | + | w.dropStaleSpans() | |||
| 198 | + | for _, col := range w.Columns { | |||
| 199 | + | if col.Span != 0 || col.spanStamp != 0 { | |||
| 200 | + | t.Fatal("foreign stamp joined the lane", w.Columns) | |||
| 201 | + | } | |||
| 202 | + | } | |||
| 203 | + | } | |||