Skip to content

Commit e9939ea

Browse files
author
yan
committed
docs: record the three review findings as issues and memory
#15 every tab showed the first file opened — upstream does not diff text on update, and the coordinator that works around it looks redundant enough that the next person would delete it without reading why. MEMORY.md #18 exists for that, with the upstream code quoted and the .id(document.id) fallback recorded. #16 a selected folder's chevron did nothing — the direct consequence of driving expansion off the selection change. Cross-linked from #12, which explains why the tap gesture was removed in the first place. #17 the gutter drew through the translucent tab strip. Marked honestly as a hypothesis rather than a diagnosis: it cannot be reproduced synthetically, and the competing explanation is the editor's content insets, with the next thing to try written down. CURRENT_STATE now records that the visual review happened and found three things, none of which were visible without someone looking at the running app. ARCHITECTURE accounts for the fourth upstream-touching file.
1 parent dcf4acf commit e9939ea

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎docs/ARCHITECTURE.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ Anything that grows a filesystem dependency should use it.
181181

182182
- `SourceEditor` and `EditorTheme.Attribute` — contained in `CodeEditorView.swift` and
183183
`EditorTheme+Bridge.swift`. Both are upstream, both are pre-1.0. See [STACK.md](STACK.md).
184+
- `DocumentTextCoordinator` — a `TextViewCoordinator` that captures the live
185+
`TextViewController` so `CodeEditorView` can reload its text. Exists because
186+
`updateNSViewController` does not diff the text behind the binding. A fourth upstream-type
187+
file is expected and accounted for; see [MEMORY.md #18](MEMORY.md).
184188
- `SourceEditorState.findPanelVisible` — `EditorState.isFindVisible` is our flag,
185189
`CodeEditorView` syncs it both ways, and the upstream coordinator opens the panel when
186190
state disagrees with it. The panel stays the authority on its own visibility.

‎docs/CURRENT_STATE.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ Create file, create folder, rename, delete, reveal in Finder, copy path. Dotfile
4343
New items land beside the active document, or at the workspace root.
4444

4545
**Editing.** `SourceEditor` from CodeEditSourceEditor 0.15, bound two-way to
46-
`Document.content`. Tree-sitter highlighting across roughly 25 languages, line-number
46+
`Document.content`. Three defects found in visual review of [#14](https://github.com/Yan123-tech/code-editor/issues/14)
47+
were fixed: every tab showed the first file opened
48+
([#15](https://github.com/Yan123-tech/code-editor/issues/15) — upstream does not diff text on
49+
update), a selected folder's chevron did nothing
50+
([#16](https://github.com/Yan123-tech/code-editor/issues/16)), and the gutter drew through the
51+
translucent tab strip while rubber-band scrolling
52+
([#17](https://github.com/Yan123-tech/code-editor/issues/17) — fix applied, not yet
53+
confirmed). Tree-sitter highlighting across roughly 25 languages, line-number
4754
gutter, bracket-pair emphasis, indentation and reformat-at-column, word wrap, undo stack
4855
shared with the document model. Peripherals are configured explicitly: gutter on, minimap
4956
off by default with a toggle, folding ribbon and invisibles toggleable, smart quotes and
@@ -189,8 +196,10 @@ feel urgent, but it is C interop behind a protocol and nothing else depends on i
189196

190197
### Housekeeping before the next branch
191198

192-
- [#14](https://github.com/Yan123-tech/code-editor/issues/14) has one unchecked box: a human
193-
visual review of the redesign. Everything else about it is verified except that.
199+
- [#16](https://github.com/Yan123-tech/code-editor/issues/16) and
200+
[#17](https://github.com/Yan123-tech/code-editor/issues/17) are fixed but were not driven in
201+
the running app — synthetic accessibility events do not reach SwiftUI rows, and the gutter
202+
overlap only appears mid-gesture. Both need a second look.
194203
- `Scripts/build-app.sh` needs running from a clean checkout before it is believed again.
195204
See [MEMORY.md #16](MEMORY.md#16-scriptsbuild-appsh-only-fails-from-a-clean-checkout).
196205

‎docs/MEMORY.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,37 @@ in the UI.
320320

321321
---
322322

323+
## 18. `SourceEditor` never diffs its text on update
324+
325+
`SourceEditor.updateNSViewController` compares language, configuration and highlight
326+
providers. It does **not** compare the text behind its `Binding<String>`. Text is pushed once,
327+
in `makeNSViewController`:
328+
329+
```swift
330+
case .binding(let binding):
331+
controller.textView.setText(binding.wrappedValue)
332+
```
333+
334+
SwiftUI reuses the view controller, so `make` is not called again when the document changes.
335+
Every tab therefore shows the first file opened, until you switch to a file of a *different
336+
language*, which forces the reload.
337+
338+
**`DocumentTextCoordinator` exists for this and only this.** It captures the controller in
339+
`prepareCoordinator` — the one hook that hands it out — and `CodeEditorView` calls
340+
`reload(text:)` on `document.id` change. It compares against `textView.string` first, so
341+
reloading identical text is free, and `Document.setContent` guards on equality so the
342+
write-back records no edit.
343+
344+
Do not remove it because it looks redundant — it is not, and the symptom is severe enough to
345+
look like a broken app. If upstream 0.16 diffs text on update, delete the coordinator then.
346+
347+
`.id(document.id)` on the editor is the fallback if this ever stops working: correct, but it
348+
rebuilds the tree-sitter highlighter on every tab switch and discards scroll and cursor state.
349+
350+
---
351+
352+
---
353+
323354
## Quick reference
324355

325356
| Question | Answer |
@@ -336,4 +367,5 @@ in the UI.
336367
| Can I derive isDark from colours? | No. #11. |
337368
| Why did the status bar say "1 line selected"? | #17. A caret is not a selection. |
338369
| Does `Scripts/build-app.sh` build? | Only since the fix in #16. Run it from clean to check. |
370+
| Why do all my tabs show the same file? | #18. `SourceEditor` does not diff text on update. |
339371
| Where do I write "this does not work"? | Here, and [CURRENT_STATE.md](CURRENT_STATE.md). |

0 commit comments

Comments
 (0)