@@ -2462,6 +2462,99 @@ describe('Options Proxy handleOptionChange', () => {
24622462
24632463 expect ( term . options . cursorStyle ) . toBe ( 'underline' ) ;
24642464 } ) ;
2465+
2466+ test ( 'changing fontSize updates renderer and resizes canvas' , async ( ) => {
2467+ if ( ! container ) return ;
2468+
2469+ const term = await createIsolatedTerminal ( { fontSize : 15 , cols : 80 , rows : 24 } ) ;
2470+ term . open ( container ) ;
2471+
2472+ // @ts -ignore - accessing private for test
2473+ const renderer = term . renderer ;
2474+
2475+ // Verify initial font size
2476+ // @ts -ignore - accessing private for test
2477+ expect ( renderer . fontSize ) . toBe ( 15 ) ;
2478+
2479+ // Change font size
2480+ term . options . fontSize = 20 ;
2481+
2482+ // Verify option was updated
2483+ expect ( term . options . fontSize ) . toBe ( 20 ) ;
2484+
2485+ // Verify renderer's internal fontSize was updated
2486+ // @ts -ignore - accessing private for test
2487+ expect ( renderer . fontSize ) . toBe ( 20 ) ;
2488+
2489+ // Verify metrics were recalculated (getMetrics returns a copy)
2490+ const metrics = renderer . getMetrics ( ) ;
2491+ expect ( metrics ) . toBeDefined ( ) ;
2492+ expect ( metrics . width ) . toBeGreaterThan ( 0 ) ;
2493+ expect ( metrics . height ) . toBeGreaterThan ( 0 ) ;
2494+
2495+ term . dispose ( ) ;
2496+ } ) ;
2497+
2498+ test ( 'changing fontFamily updates renderer' , async ( ) => {
2499+ if ( ! container ) return ;
2500+
2501+ const term = await createIsolatedTerminal ( { fontFamily : 'monospace' , cols : 80 , rows : 24 } ) ;
2502+ term . open ( container ) ;
2503+
2504+ // @ts -ignore - accessing private for test
2505+ const renderer = term . renderer ;
2506+
2507+ // Change font family
2508+ term . options . fontFamily = 'Courier New, monospace' ;
2509+
2510+ // Verify option was updated
2511+ expect ( term . options . fontFamily ) . toBe ( 'Courier New, monospace' ) ;
2512+
2513+ // Verify renderer was updated
2514+ // @ts -ignore - accessing private for test
2515+ expect ( renderer . fontFamily ) . toBe ( 'Courier New, monospace' ) ;
2516+
2517+ term . dispose ( ) ;
2518+ } ) ;
2519+
2520+ test ( 'font change clears active selection' , async ( ) => {
2521+ if ( ! container ) return ;
2522+
2523+ const term = await createIsolatedTerminal ( { fontSize : 15 , cols : 80 , rows : 24 } ) ;
2524+ term . open ( container ) ;
2525+
2526+ // Write some text and select it
2527+ term . write ( 'Hello World' ) ;
2528+ term . select ( 0 , 0 , 5 ) ; // Select "Hello"
2529+ expect ( term . hasSelection ( ) ) . toBe ( true ) ;
2530+
2531+ // Change font size
2532+ term . options . fontSize = 20 ;
2533+
2534+ // Selection should be cleared (pixel positions changed)
2535+ expect ( term . hasSelection ( ) ) . toBe ( false ) ;
2536+
2537+ term . dispose ( ) ;
2538+ } ) ;
2539+
2540+ test ( 'font change maintains terminal dimensions (cols/rows)' , async ( ) => {
2541+ if ( ! container ) return ;
2542+
2543+ const term = await createIsolatedTerminal ( { fontSize : 15 , cols : 80 , rows : 24 } ) ;
2544+ term . open ( container ) ;
2545+
2546+ const initialCols = term . cols ;
2547+ const initialRows = term . rows ;
2548+
2549+ // Change font size
2550+ term . options . fontSize = 20 ;
2551+
2552+ // Cols and rows should remain the same (canvas grows instead)
2553+ expect ( term . cols ) . toBe ( initialCols ) ;
2554+ expect ( term . rows ) . toBe ( initialRows ) ;
2555+
2556+ term . dispose ( ) ;
2557+ } ) ;
24652558} ) ;
24662559
24672560// ==========================================================================
0 commit comments