## Summary of the Pull Request
Adds a new Hosts File Editor setting “No leading spaces” that prevents
prepending spaces to active lines when saving the hosts file (when any
entry is disabled). Default is Off to preserve current behavior.
## PR Checklist
- [x] Closes: #36386
- [ ] Communication: N/A (small, scoped option)
- [x] Tests: Added/updated and all pass
- [x] Localization: New en-US strings added; other locales handled by
loc pipeline
- [ ] Dev docs: N/A
- [x] New binaries: None
- [x] Documentation updated: N/A
## Detailed Description of the Pull Request / Additional comments
- Settings surface:
- `src/settings-ui/Settings.UI.Library/HostsProperties.cs`: add
`NoLeadingSpaces`
- `src/modules/Hosts/HostsUILib/Settings/IUserSettings.cs`: add
`NoLeadingSpaces`
- `src/modules/Hosts/Hosts/Settings/UserSettings.cs`: load/save value
from settings.json
- `src/settings-ui/Settings.UI/ViewModels/HostsViewModel.cs`: expose
`NoLeadingSpaces`
- `src/settings-ui/Settings.UI/SettingsXAML/Views/HostsPage.xaml`: new
SettingsCard toggle
- `src/settings-ui/Settings.UI/Strings/en-us/Resources.resw`: add
`Hosts_NoLeadingSpaces.Header/Description`
- Writer change:
- `src/modules/Hosts/HostsUILib/Helpers/HostsService.cs`: gate indent
with `anyDisabled && !_userSettings.NoLeadingSpaces`
- Tests:
- `src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs`:
`NoLeadingSpaces_Disabled_RemovesIndent`
Backward compatibility: default Off, current formatting unchanged unless
the user enables the option.
## Validation Steps Performed
- Automated: `HostsEditor.UnitTests` including
`NoLeadingSpaces_Disabled_RemovesIndent` passing.
- Manual:
1. Run PowerToys (runner) as Admin.
2. Settings → Hosts File Editor → enable “No leading spaces”.
3. In editor, add active `127.0.0.10 example1` and disabled
`127.0.0.11 example2`; Save.
4. Open `C:\Windows\System32\drivers\etc\hosts` in Notepad.
- ON: active line starts at column 0; disabled is `# 127...`.
- OFF: active line begins with two spaces when a disabled entry
exists.
* [DSC] Microsoft.PowerToys.Configure module + winget configuration file support
* f: fix for an incorrect directory id reference
* f: update comment
* f: address review comments
* f: file locksmith bug fix
* f: add explorer preview switches in samples
* f: remove debug
* Sign DSC files
* f: implement docs/samples generator
* [ci]Sign FancyZonesEditorCommon.dll
* Sign DSC files in the Generated folder
* f: address review comments
* f: update usable options
* f: add autogenerated sample
* [Installer] Don't use same GUID for different components
* [Installer]Don't remove folders shared by other modules
* Allow configuring PTRun MaximumNumberOfResults
* Remove all settings DSC sample. Just random data
* Allow configuring Hosts Run as Administrator
* Revert "[Installer]Don't remove folders shared by other modules"
This reverts commit 6da3d6cfd5.
* Add all PTRun plugins and Global and keyboard to DSC sample
* Fix issues with context menu modules not disabling
* Fix default enabled values when setting with DSC
* Fix tests regarding default modules in Settings
* Fix merge error
* Restart PowerToys process if we stopped it
---------
Co-authored-by: Andrey Nekrasov <1828123+yuyoyuppe@users.noreply.github.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>