261024.3 · 62aecba7acc76906e342a15545ff1a8c9899d89d
fix(resize): size the nested parser on a window size report
reading declarations
@@ -1513,6 +1513,11 @@ func (ip *inputParser) handleCsi(mode rune, params []byte, intermediate []byte) if height != ip.rows || width != ip.cols { // Not through SetSize's goroutine, so that the pixel size report sent after it is paired with this size. ip.rows, ip.cols = height, width+ if nested := ip.nested; nested != nil {+ nested.l.Lock()+ nested.rows, nested.cols = height, width+ nested.l.Unlock()+ } ip.post(newEventResize(WindowSize{Width: width, Height: height})) } return
@@ -1681,3 +1681,37 @@ func TestInputWindowAndPixelSizeReports(t *testing.T) { } } }++// TestInputWindowSizeReportNested tests that a window size report also sizes the nested Win32 parser, without a second resize event.+func TestInputWindowSizeReportNested(t *testing.T) {+ evch := make(chan Event, 10)+ ip := newInputParser(evch)+ ip.rows, ip.cols = 25, 80+ nested := newInputParser(evch)+ nested.rows, nested.cols = 25, 80+ ip.nested = nested++ ip.ScanUTF8([]byte("\x1b[8;30;100t"))++ nested.l.Lock()+ rows, cols := nested.rows, nested.cols+ nested.l.Unlock()+ if rows != 30 || cols != 100 {+ t.Errorf("Expected nested size 100x30, got %dx%d", cols, rows)+ }++ select {+ case ev := <-evch:+ if width, height := ev.(*EventResize).Size(); width != 100 || height != 30 {+ t.Errorf("Expected size 100x30, got %dx%d", width, height)+ }+ case <-time.After(100 * time.Millisecond):+ t.Fatal("Timeout waiting for resize event")+ }++ select {+ case ev := <-evch:+ t.Errorf("Expected one resize event, got another %T", ev)+ case <-time.After(50 * time.Millisecond):+ }+}