[PR #19645] Refactor SCREEN_INFORMATION to use in-class initializers (#962) #31909

Open
opened 2026-01-31 09:50:19 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/19645

State: closed
Merged: Yes


Refactor SCREEN_INFORMATION Constructor Initializers

Summary

This PR refactors the legacy SCREEN_INFORMATION class to use in-class member initializers for members with constant or default values, replacing equivalent entries in the constructor initializer list.

This change aligns the class with C++ Core Guidelines C.48 (“Prefer in-class initializers to member initializers in constructors for constant initializers”) while preserving existing behavior.


Motivation

SCREEN_INFORMATION relied heavily on constructor member initializers for values that are constant or represent default state. This made it harder to reason about default object state and conflicted with the guideline the project references.

This PR addresses the issue in a minimal, mechanical, and well-scoped way, without attempting a broad codebase migration.


Changes

src/host/screenInfo.hpp

  • Added in-class default member initializers for members previously initialized with constant values.
  • Examples include:
    • WheelDelta, HWheelDelta
    • _textBuffer
    • Next
    • WriteConsoleDbcsLeadByte, FillOutDbcsLeadChar
    • ScrollScale
    • _api, _stateMachine
    • _psiAlternateBuffer, _psiMainBuffer
    • _fAltWindowChanged
    • _virtualBottom

src/host/screenInfo.cpp

  • Removed redundant constructor member initializers corresponding to the in-class defaults.
  • Members that depend on constructor parameters remain in the initializer list.

Verification

Automated Tests

  • Status: Not run
  • Reason: Build and test tools (msbuild, vstest.console.exe) are not available in the current environment.

Manual Verification

  • Performed strict code inspection to ensure a one-to-one correspondence between removed constructor initializers and added in-class initializers.
  • Verified that initialization semantics remain unchanged.

Notes

  • This is a mechanical refactor only; no functional or behavioral changes are intended.
  • No members with parameter-dependent initialization were moved to in-class initializers.
  • The scope is intentionally limited to a single legacy class and may serve as a reference for similar refactors in the future.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/19645 **State:** closed **Merged:** Yes --- ## Refactor `SCREEN_INFORMATION` Constructor Initializers ### Summary This PR refactors the legacy `SCREEN_INFORMATION` class to use **in-class member initializers** for members with constant or default values, replacing equivalent entries in the constructor initializer list. This change aligns the class with **C++ Core Guidelines C.48** (*“Prefer in-class initializers to member initializers in constructors for constant initializers”*) while preserving existing behavior. --- ### Motivation `SCREEN_INFORMATION` relied heavily on constructor member initializers for values that are constant or represent default state. This made it harder to reason about default object state and conflicted with the guideline the project references. This PR addresses the issue in a **minimal, mechanical, and well-scoped way**, without attempting a broad codebase migration. --- ### Changes #### `src/host/screenInfo.hpp` - Added in-class default member initializers for members previously initialized with constant values. - Examples include: - `WheelDelta`, `HWheelDelta` - `_textBuffer` - `Next` - `WriteConsoleDbcsLeadByte`, `FillOutDbcsLeadChar` - `ScrollScale` - `_api`, `_stateMachine` - `_psiAlternateBuffer`, `_psiMainBuffer` - `_fAltWindowChanged` - `_virtualBottom` #### `src/host/screenInfo.cpp` - Removed redundant constructor member initializers corresponding to the in-class defaults. - Members that depend on constructor parameters remain in the initializer list. --- ### Verification #### Automated Tests - **Status:** Not run - **Reason:** Build and test tools (`msbuild`, `vstest.console.exe`) are not available in the current environment. #### Manual Verification - Performed strict code inspection to ensure a one-to-one correspondence between removed constructor initializers and added in-class initializers. - Verified that initialization semantics remain unchanged. --- ### Notes - This is a **mechanical refactor** only; no functional or behavioral changes are intended. - No members with parameter-dependent initialization were moved to in-class initializers. - The scope is intentionally limited to a single legacy class and may serve as a reference for similar refactors in the future.
claunia added the pull-request label 2026-01-31 09:50:19 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31909