Repository navigation
mac editor: text typed at the edge of the painted window is coloured (#280) - #309
Conversation
…itch (GH#280, probe) The regression tests #280 asks for. Each opens a document into a fresh editor with no document switch, then asserts that (a) the text carries syntax-colour temporary attributes, (b) typing \se through keyDown requests the list once and a real completion session opens, and (c) the typed command is coloured. Three hostings: - the bare SourceEditorView with the document present before mount; - the bare SourceEditorView with the document opened after mount; - the whole ContentView at the app's 1200x640 minimum size. All three pass on main 9bd4b02, so the owner's report does NOT reproduce under hosted conditions. Since the reported 8a5ac44 build, only 0f8ba91 (#300, popup appearance) has touched the editor sources. Ruled out by reading the code: view identity (EditorPane has no .id), the empty visible-window paint (window(for:) paints everything without a window), and diagnostic marks clearing the colours (MarkPainter removes only underline/tooltip keys). What remains differs between these tests and the bundled app: a key/active window, an attached producer delivering compile results, launch-time session/seed paths, and preferences such as Vim keybindings. Findings and questions are on #280. Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan) Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback) Co-authored-by: d-q222 <[email protected]> Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
…(GH#280)
Measured cause. SyntaxPainter tracks `painted` ranges, the text whose
temporary colours match the highlighter, and an edit's flush repaints only
`painted ∩ dirty`. Its range arithmetic treated an edit that starts exactly at
a painted range's end, or ends exactly at its start, as outside the range.
Text typed at either edge was therefore never inside `painted` and never
coloured. It only turned colour when something else repainted: a scroll, or a
document switch, whose text reset repaints the window. That is the owner's
"eventually comes" and "click another file and back".
The startup document shows it directly. In the whole ContentView hosted like
the app, with the caret at the end of the fixture text, typing " \se" left
painted == [{0, 16}] over a 20-character text with 0 colour runs, while the
highlighter held 1 run for \se.
Fix: `shifted` joins edits that touch a range, using strict comparisons. The
existing union branch already yields the right range for touching insertions
and deletions; the new unit test pins eight cases.
Tests (EditorFirstFocusTests):
- testPaintedRangeAbsorbsEditsAtItsEdges and
testStartupDocumentInContentViewIsColouredAndCompletes FAIL without this
change and pass with it (verified by reverting only the source file);
- the three earlier first-focus probes still pass.
The completion half of the report did not reproduce: the list opens on first
focus in every hosting. The owner's non-activating launch (window never key)
is still to be checked in the real app.
Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan)
Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback)
Co-authored-by: d-q222 <[email protected]>
Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
…w event dispatch) Skipped unless FLASHTEX_FOCUS_PROBE=1 because it takes keyboard focus. It hosts the whole ContentView in a window that was only ordered back, as in the owner's non-activating launch, then sends a real mouse click and real keyDown events through NSWindow.sendEvent. With #309 on this branch, the click gives the editor first responder (the window is still not key), the keys insert, typing \se opens a session, the CompletionPopup child window is visible, and the command is coloured. So completion on first focus does not reproduce through the real event path either. Left to check: app activation from an open -g launch, which a test process cannot emulate. Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro plan) Commit-Executor: daniel-vpclaude, direct git (Cursor-limit fallback) Co-authored-by: d-q222 <[email protected]> Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
|
Update ( |
|
daniel-parent Mac pre-merge verification (for the integration lane, which has no Swift toolchain). Xcode 26.6, macOS 26.6, merged onto
About the 3 full-suite failures: |
…us (flash-tex#280) What changed: - `EditorFirstFocusTests.testSeededStartupDocumentIsColouredAndCompletesAtFirstFocus`: hosts the whole `ContentView` in a never-key window over a `ShellModel` built the way the app builds one at launch with a real `.tex` already open (`FLASHTEX_SEED_FILE`), then asserts the text is coloured with no keystroke and no document switch, and that typing `\se` opens the list. - This shape had no coverage. The existing startup test loads the `protocol/fixtures` request, whose text is `Hello FlashTeX.` -- it holds no LaTeX token, so it can only assert that *typed* text gets coloured, never that the document the editor opened with is coloured. That is precisely what flash-tex#280 reported. - No production change: the behaviour flash-tex#280 describes no longer reproduces (measured below); flash-tex#309 fixed the colouring half and the completion half opens on every hosting tried. - The completion half is guarded by `XCTSkipIf(Completion.defaultSupported.isEmpty)` naming flash-tex#704, so when the bundled inventory does not reach the test bundle this says so instead of failing as an opaque "timed out waiting for the list". The colouring assertion runs unconditionally -- it needs no inventory. What was run: swift test --filter 'EditorFirstFocusTests|SourceEditorViewTests|AutomaticCompletionTests' Executed 37 tests, with 1 test skipped and 0 failures (0 unexpected) in 5.459 seconds swift test --filter 'EditorFirstFocusTests' (new test, alone) Test Case '-[FlashTeXMacTests.EditorFirstFocusTests testSeededStartupDocumentIsColouredAndCompletesAtFirstFocus]' passed (0.136 seconds) Executed 8 tests, with 1 test skipped and 0 failures (0 unexpected) in 1.252 seconds Same, with the bundled inventory removed from the test bundle (flash-tex#704's state): Test Case '-[...testSeededStartupDocumentIsColouredAndCompletesAtFirstFocus]' skipped (0.113 seconds) (the colouring assertion ran and passed before the skip) flash-tex#280 measurement, instrumented run of the owner's repro shape: PROBE seed: docs=["hw1.tex"] text="\documentclass{article}\n\begin{document}\n\section{Intro} Some $x^2$ text.\n\n\end{document}\n" PROBE seed: colourRuns at first focus=19 PROBE seed: after typing colourRuns=22 before=19 autoOpen=1 active=true items=Optional(10) Next step: - flash-tex#280's residual symptom in any non-packaged build is flash-tex#704 (the completion vocabulary not reaching the bundle), which is separately claimed. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Fixes the syntax-colouring half of #280. Lane
daniel-vpclaude(Claude Pro, mac-m5pro-dq222), allocated by the Commander on #2 at 04:53Z. Based on main9bd4b025. Test-merges cleanly on top of #236 + #245.Measured cause
SyntaxPainterkeepspaintedranges, the text whose temporary colours match the highlighter. After an edit,flush()repaints onlypainted ∩ dirty.SyntaxPainter.shiftedtreated an edit that starts exactly at a painted range's end (or ends exactly at its start) as outside the range. So text typed at either edge never enteredpaintedand was never coloured. It only got coloured when something else repainted it:scrolled()fills gaps), which is the owner's "eventually comes";Reproduction: the whole
ContentViewhosted like the app, with the fixture startup document (no File ▸ Open, as in the owner's repro context) and the caret at the end. Typing\seleftpainted == [{0, 16}]over a 20-character text, with 0 colour runs, while the highlighter held 1 run for\se.Fix
shifteduses strict comparisons, so a touching edit joins the range. The existing union branch already gives the right result for touching insertions and deletions, and 8 cases are pinned in a unit test. The function also becomesinternalso the test can call it.Tests:
EditorFirstFocusTeststestPaintedRangeAbsorbsEditsAtItsEdges(8 edge cases)testStartupDocumentInContentViewIsColouredAndCompletesContentViewafter ⌘O-style open): colours + a real\secompletion session, no document switch"Without fix" was verified by reverting only
SyntaxHighlighter.swift.Full
swift test: 1063 tests, 133 skipped. The only failures were 2 tests inWordCountModelTests(3 assertion failures), which timed out at about 2 s under full-suite load and pass in isolation (0.03 s each). They're unrelated to this change. #256's two known failures didn't appear.Not fixed / open
ContentView. Per the Commander's repro note, the owner's app was launchedFLASHTEX_NO_ACTIVATE=1 open -g(window never key). A key-window-only cause isn't covered by these non-activating tests. If completion still fails in the real app with this build, that part needs a real-app check. I've left IDE: syntax highlighting and completion are absent when the editor first gets focus; appear after switching files and back #280 open for it rather than claiming it's fixed.🤖 Generated with Claude Code
https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ