Repository navigation
fix: skip autostart toggle when state already matches so settings always save - #1
Merged
poneding merged 1 commit intoSep 30, 2026
Conversation
…ays save auto-launch's disable() errors when the HKCU Run entry is already absent, which aborted set_settings before settings.json was written; every save with launchAtLogin=false and no autostart entry therefore failed silently, losing language and hotkey changes across restarts. Query the current autostart state first and only toggle the registry entry when it differs from the requested state.
Owner
|
thanks for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, settings changes (language, hotkeys, theme, …) are silently lost on every restart when "launch at login" is disabled and no autostart entry exists in
HKCU\...\Run.auto-launch'sdisable()returns an error when the registry value it is asked to delete does not exist. Sinceset_settingsapplies the login-startup toggle before persisting, that error abortsset_settingsbeforesettings.jsonis ever written — and the frontend swallows the error, so the failure is invisible:Reproduction: fresh install (no
Runentry) withlaunchAtLogin: false(the default) → change language tozh-CN→ restart → language reverts toen, andAppData\Roaming\flashot\settings.jsonwas never created.Fix
Query the current autostart state first and only touch the registry when it differs from the requested state:
is_enabledto theLaunchAtLogintrait (delegating toAutoLaunchManager::is_enabled)apply_launch_at_loginwhenis_enabled()? == launch_at_loginFakeLaunchAtLoginwith an enabled state and add a regression test covering the exact failing path (apply_launch_at_login_skips_disable_when_autostart_already_off), plus state-transition assertions on the existing enable/disable testsTesting
cargo test apply_launch_at_login— 3 passed (including the new regression test)settings.jsonwritten immediately → persists across restarts中文说明
问题: 未开启开机自启且注册表
Run项不存在时,auto-launch的disable()会因"值不存在"报错,导致set_settings在写入settings.json之前就中断,前端又静默吞掉错误——表现为"改语言/快捷键当次生效、重启后还原"。修复: 先查询自启状态,状态与请求一致时直接跳过注册表操作,并补充回归测试。