mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
Start with the default app state if state.yml can't be parsed
Several users on Windows reported that lazygit wouldn't start any more and failed with "yaml: control characters are not allowed" (#3023). Their state.yml was filled with zero bytes, most likely because the machine crashed or lost power shortly after lazygit had written the file. They had to find the file and delete it to make lazygit start again. Start with the defaults in this case. The file holds things like the shell command history and the recent repos list; losing them is better than not starting. The next save replaces the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d270f0e54
commit
5a6d5de3b8
2 files changed
+5
-4
No files matched your search
@@ -58,7 +58,11 @@ func loadAppState() (*AppState, error) {
|
||||
|
||||
err = yaml.Unmarshal(appStateBytes, appState)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Nothing in state.yml is important enough to keep lazygit from
|
||||
// starting. So if it can't be parsed (users have seen it filled with
|
||||
// zero bytes after a crash), start with the defaults. The next save
|
||||
// replaces the file.
|
||||
return getDefaultAppState(), nil
|
||||
}
|
||||
|
||||
return appState, nil
|
||||
|
||||
@@ -31,8 +31,5 @@ func TestStartupWithBrokenAppStateFile(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = newAppConfig(t)
|
||||
/* EXPECTED:
|
||||
assert.NoError(t, err)
|
||||
ACTUAL: */
|
||||
assert.ErrorContains(t, err, "control characters are not allowed")
|
||||
}
|
||||
Reference in new issue
Block a user