microsoft / microsoft/terminal
Reload environment variables only on WM_SETTINGCHANGE
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
`til::env` is rather complex, reads a lot of registry keys and requires lots of string operations. Since #14999 we recreate the `til::env` cache every time we create a new tab, but this isn't necessary, considering that changes to environment variables are _exceedingly_ rare. Most users will run a Windows Terminal instance without it ever seeing a single environment variable change.
👉 Listen to `WM_SETTINGCHANGE` and only then recreate the globally shared cache. If multi-threading is a concern, just encode the variables back into a `\0` separated string, the same way we get it from the OS anyways already. This would reflect how ConEmu does it: https://github.com/Maximus5/ConEmu/issues/468
Contributor guide
Research direction
Start by tracing where the globally shared til::env cache is created for new tabs, with #14999 as context, and locate Windows Terminal's handling of WM_SETTINGCHANGE. Confirm how the cache is shared across threads. Done means the cache is recreated only after the relevant setting-change message while preserving safe access to its environment data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100