1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! The single "are edamame's own persisted files in play at all?" gate behind `--no-config`.
//! See `docs/dev/cli.md`.
//!
//! Named for the config dir it was born to guard, but the scope is broader than the name: it
//! governs every file edamame reads or writes on the user's behalf, in *both* the config dir
//! (`~/.config/edamame` — `config.toml`, themes, keybindings, export stylesheets) and the data
//! dir (`state.toml`; see [`crate::config::State`]). `--no-config` means a pristine,
//! non-persistent session, so the data-dir bookkeeping is suppressed alongside the config.
//!
//! A process-global rather than a `Config` field: `App::open_config_in_editor` replaces
//! `self.config` with a freshly deserialized one mid-session, which reverted a field to
//! its serde default and silently lapsed the guarantee.
//!
//! Both halves matter. Every write asks [`config_writes_allowed`]; skipping the *startup* load
//! is not enough for reads, because the theme and export stylesheet listings — and `State::load`
//! — re-read from disk long after `main` branched, so they ask [`config_reads_allowed`]. A new
//! reader or writer owes the matching check. (`Config::ensure_default_files` is exempt only
//! because `main` never calls it here.)
use ;
/// Whether edamame's persisted files (config dir *and* data dir) participate in this run at all.
/// Starts `true`; only [`disable_config_dir`] ever clears it, and nothing sets it back.
static CONFIG_DIR_IN_USE: AtomicBool = new;
/// What a "saved" message says instead when the write was suppressed. The setting *is*
/// live for the session; only the disk write was skipped.
pub const NOT_PERSISTED_NOTE: &str = " (not saved: --no-config)";
/// Take edamame's persisted files (config dir and data dir) out of play for the rest of the
/// process, in both directions. Called once from `main` before any such file is touched. There
/// is deliberately no way to re-enable: a mid-session reversal is the bug this design exists to
/// prevent.
/// The write half of the gate. `Relaxed` suffices: the value is written once at startup
/// on the main thread, before any other thread exists, and every later access is a read.
/// The read half of the gate. Same flag as [`config_writes_allowed`]; separate only so a
/// reader isn't guarded by a function with "writes" in its name.
/// Suffix for a flash reporting a settings change: empty on an ordinary run,
/// [`NOT_PERSISTED_NOTE`] when writes are suppressed. Callers phrase the sentence so
/// both readings are true.
/// Test-only scoped suppression, serialized by [`crate::test_env::env_lock`] rather than a
/// mutex of its own.
///
/// **Callers must hold `env_lock` for the whole test**, not just across the guard's
/// lifetime: these tests are shaped "assert nothing was written, drop the guard, assert the
/// same call *does* write", and the second half would fail if another test's guard were
/// live then.
pub ;