Skip to content

feat(files): open text in editor and retain syntax tokens - #767

Merged
nixuuu merged 5 commits into
devfrom
fix/files-highlighting-editor
Nov 15, 2026
Merged

nixuuu merged 5 commits into
devfrom
fix/files-highlighting-editor

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Writable text files now open directly in the editor. Typing pins a preview tab; saving and discarding keep the editor, cursor and undo state mounted. Files without write permission, linked or offline computers, images, binary files and files above the edit limit stay read only. Dirty drafts remain visible when editing becomes unavailable.

Scrolling used to replace the reader token map and debounce editor decorations for each viewport. The tokenizer kept grammar checkpoints but discarded line tokens. Both web surfaces now consume persistent line tokens from one background executor, which prepares the file in bounded batches and invalidates the grammar suffix after edits. Token memory and execution time stay bounded; pathological long lines retain readable plain text. Mobile removes the same edit toggle and retains/prefetches highlight windows in its existing JS reader. Its native TextInput still uses plain text while typing and highlighted Preview changes.

Related: #640, #648

Validation: install, generated-contract check, full typecheck, lint, formatting check and web production build passed. The syntax regression tests passed (5 tests, 112 assertions), covering a 20k-line multiline grammar revisit, edits and JSON/YAML/Python. Browser review used an isolated synthetic stack: light/dark, desktop/390px phone, small/20k-line files, a 50k-character line, TypeScript/Python/JSON/YAML, permission/size/binary/image read-only cases, dirty availability loss, save/discard and close protection. No UI suites or full integration/check:tmp run. Native device behavior and generated Expo fingerprint hashes were not measured; native dependency/config/module inputs and lockfile are unchanged.

Scroll measurements (Chromium 157, 1280×800, Vite, 20,000 lines/308,889 bytes, 360 rAF frames forward/back, without recording):

Surface Before p95 After p95 Plain visible-line samples before → after
Reader, warm cache 16.8 ms 16.7 ms 12,583/12,652 → 0/12,652
Editor 16.7 ms 16.7 ms 1,002/11,802 → 0/11,802

Final editor maximum was 16.8 ms, with no intervals above 33.4 ms. These are rAF intervals, not compositor presentation timings. First coloring is asynchronous: an immediate cold reader sweep still sampled 2,073/12,652 plain lines during grammar startup. Returning to prepared lines does not repeat that transition. Recordings add substantial overhead and were excluded from frame-time conclusions. Evidence is kept outside the repository in /var/tmp/canopy-file-viewer-shots/.

Copy audit (§8): removed Edit/Stop editing; retained Save file/Discard changes and their existing confirmation behavior. Read only and offline/other-computer explanations describe the current state and the recovery action. Labels remain English, use existing terms and sentence case, and fit phone/desktop layouts in both themes. No internal tokenizer details were added to the user flow.

@nixuuu
nixuuu force-pushed the fix/files-highlighting-editor branch from c6e15e7 to e2f809e Compare November 15, 2026 00:20
@nixuuu
nixuuu marked this pull request as ready for review November 15, 2026 00:37
@nixuuu
nixuuu merged commit fd49a2c into dev Nov 15, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/files-highlighting-editor branch November 15, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant