@@ -172,19 +172,28 @@ export default class TerminalComponent {
172172
173173 // Handle keyboard resize cursor positioning
174174 const heightRatio = size . rows / originalRows ;
175- if ( heightRatio < 0.75 && this . terminal . buffer && this . terminal . buffer . active ) {
175+ if (
176+ heightRatio < 0.75 &&
177+ this . terminal . buffer &&
178+ this . terminal . buffer . active
179+ ) {
176180 // Keyboard resize detected - ensure cursor is visible
177181 const buffer = this . terminal . buffer . active ;
178182 const cursorY = buffer . cursorY ;
179183 const cursorViewportPos = buffer . baseY + cursorY ;
180184 const viewportTop = buffer . viewportY ;
181185 const viewportBottom = viewportTop + this . terminal . rows - 1 ;
182-
183- if ( cursorViewportPos <= viewportTop + 1 || cursorViewportPos >= viewportBottom - 1 ) {
184- const targetScroll = Math . max ( 0 ,
185- Math . min ( buffer . length - this . terminal . rows ,
186- cursorViewportPos - Math . floor ( this . terminal . rows * 0.25 )
187- )
186+
187+ if (
188+ cursorViewportPos <= viewportTop + 1 ||
189+ cursorViewportPos >= viewportBottom - 1
190+ ) {
191+ const targetScroll = Math . max (
192+ 0 ,
193+ Math . min (
194+ buffer . length - this . terminal . rows ,
195+ cursorViewportPos - Math . floor ( this . terminal . rows * 0.25 ) ,
196+ ) ,
188197 ) ;
189198 this . terminal . scrollToLine ( targetScroll ) ;
190199 }
@@ -474,6 +483,9 @@ export default class TerminalComponent {
474483
475484 this . container = container ;
476485
486+ // Apply terminal background color to container to match theme
487+ this . container . style . background = this . options . theme . background ;
488+
477489 try {
478490 try {
479491 this . terminal . loadAddon ( this . webglAddon ) ;
@@ -701,16 +713,20 @@ export default class TerminalComponent {
701713 const cursorViewportPos = buffer . baseY + cursorY ;
702714 const viewportTop = buffer . viewportY ;
703715 const viewportBottom = viewportTop + this . terminal . rows - 1 ;
704-
716+
705717 // Check if cursor is fully visible (with margin to prevent half-visibility)
706- const isCursorFullyVisible = cursorViewportPos >= viewportTop + 1 && cursorViewportPos <= viewportBottom - 2 ;
718+ const isCursorFullyVisible =
719+ cursorViewportPos >= viewportTop + 1 &&
720+ cursorViewportPos <= viewportBottom - 2 ;
707721
708722 // If cursor is not fully visible, scroll to make it properly visible
709723 if ( ! isCursorFullyVisible && buffer . length > this . terminal . rows ) {
710- const targetScroll = Math . max ( 0 ,
711- Math . min ( buffer . length - this . terminal . rows ,
712- cursorViewportPos - Math . floor ( this . terminal . rows * 0.25 )
713- )
724+ const targetScroll = Math . max (
725+ 0 ,
726+ Math . min (
727+ buffer . length - this . terminal . rows ,
728+ cursorViewportPos - Math . floor ( this . terminal . rows * 0.25 ) ,
729+ ) ,
714730 ) ;
715731 this . terminal . scrollToLine ( targetScroll ) ;
716732 }
0 commit comments