Skip to content

fix typing map newline preservation#1

Draft
tail258 wants to merge 1 commit into
mainfrom
agent/preserve-typing-map-newlines
Draft

fix typing map newline preservation#1
tail258 wants to merge 1 commit into
mainfrom
agent/preserve-typing-map-newlines

Conversation

@tail258

@tail258 tail258 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

What changed

  • Disable Pygments newline normalization when building the per-character typing map.
  • Narrow the lexer fallback to ClassNotFound instead of swallowing unrelated exceptions.
  • Add standard-library unit tests for missing trailing newlines, multiple trailing newlines, and unknown filename extensions.

Why

Pygments enables stripnl and ensurenl by default. That changed the source text before tokenization, so the generated typing map could gain a phantom final newline or lose trailing blank lines. The editor renders the original source, making its character positions diverge from the map.

Impact

Typing progress now remains aligned with the exact source text. Existing lexer selection, syntax categories, comment skipping, and the public TypingMapBuilder.build_map interface are unchanged. No new dependencies are introduced.

Validation

  • python -m unittest discover -s tests -v — 3 tests passed
  • python -m compileall -q core gui main.py tests — passed
  • Verified all 4 bundled snippets round-trip exactly through TypingMapBuilder

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