diff --git a/pkg/config/app_state.go b/pkg/config/app_state.go index 231d28d01..efa2e9757 100644 --- a/pkg/config/app_state.go +++ b/pkg/config/app_state.go @@ -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 diff --git a/pkg/config/app_state_test.go b/pkg/config/app_state_test.go index 5558d6b08..6236d08cc 100644 --- a/pkg/config/app_state_test.go +++ b/pkg/config/app_state_test.go @@ -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") }