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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! Editor-global resources shared into every `Window` by `Arc` clone.
//!
//! ## Why this exists
//!
//! `Window` was originally constructed with only its own per-project state
//! (buffers, splits, file_explorer, lsp, …) and reached back to `Editor`
//! for everything else (`config`, `theme`, `plugin_manager`, registries,
//! filesystem authority). The reach-back forced almost every handler to
//! live on `impl Editor` rather than `impl Window`, because the body
//! needed `&self` *as Editor* to read those resources.
//!
//! `WindowResources` flips that: every editor-global service a handler
//! could plausibly need is shared into `Window` as an `Arc<…>` clone (or
//! `Clone`-by-value for handles that already carry their own `Arc`s,
//! like `Authority`). A `Window` method now has direct access to
//! `self.config.editor.line_wrap`, `self.authority().path_translation`,
//! etc., without any `Editor` reference. Methods that previously had to
//! sit on `impl Editor` to read these can move to `impl Window`.
//!
//! ## What stays on `Editor` (not in `WindowResources`)
//!
//! - `next_buffer_id` allocator (separate concept — see
//! [`BufferIdAllocator`])
//! - `theme: Theme` — direct value (not `Arc`); pending Tier-2 migration
//! - `clipboard: Clipboard` — owned value; pending Tier-2 migration
//! - `mode_registry: ModeRegistry` — owned value; pending wrap
//! - `quick_open_registry: QuickOpenRegistry` — owned value; pending wrap
//! - `event_broadcaster: EventBroadcaster` — owned value; needs check
//! - `plugin_manager: PluginManager` — needs `Arc<Mutex<…>>` wrapping
//! when the first hook-firing handler migrates to `impl Window`
//! - All `*_registry` types currently owned by value
//!
//! These are deliberately deferred: they can be added to `WindowResources`
//! incrementally as method migrations surface the need. Foundation PR
//! lands what's cheap to share today; later PRs widen the surface as
//! needed by each `impl Window` move.
use crateConfig;
use crateDirectoryContext;
use crateCommandRegistry;
use crateKeybindingResolver;
use crateFileSystem;
use crateGrammarRegistry;
use crateFsManager;
use crateSharedTimeSource;
use crateThemeRegistry;
use BufferId;
use HashMap;
use ;
use ;
/// Globally-unique `BufferId` allocator shared across every `Window`.
///
/// `BufferId`s must be unique editor-wide so plugin APIs that thread
/// ids around (`editor.openFile(...) -> BufferId`, `setActiveBuffer(id)`,
/// terminal `terminalId` correlation, recovery files keyed by id) don't
/// have to disambiguate by `WindowId`. The allocator is a single
/// `Arc<AtomicUsize>` cloned into every `Window` — concurrent
/// `next()` calls return distinct ids without locking.
;
/// Editor-global resources that every `Window` holds an `Arc`-cloned
/// reference to.
///
/// One instance is constructed in `editor_init` and cloned into the base
/// `Window`. `Editor::create_window` and the first-dive seed path in
/// `set_active_window` clone it into every subsequent `Window`. All
/// fields are cheap to clone (`Arc` increment or `Clone`-by-value where
/// the inner type already carries `Arc`s like `Authority`).
///
/// A `Window` handler that needs any of these reads it directly:
/// `self.resources.config.editor.line_wrap`,
/// `self.authority().path_translation`, etc. The
/// [`Window::config()`] / `Window::authority()` accessors are the
/// canonical reading API; the field itself stays `pub(crate)` so call
/// sites can split-borrow disjoint sub-fields when the borrow checker
/// needs it.