Skip to content

fix: don't drop cursor when a trailing space is typed at end of paragraph - #319

Merged
NellowTCS merged 3 commits into
TailsmanDesign:mainfrom
chrisdebian:fix/262-trailing-space-eaten
Aug 18, 2026
Merged

fix: don't drop cursor when a trailing space is typed at end of paragraph#319
NellowTCS merged 3 commits into
TailsmanDesign:mainfrom
chrisdebian:fix/262-trailing-space-eaten

Conversation

@chrisdebian

Copy link
Copy Markdown
Contributor

Fixes #262.

What and why

reflowParagraphCore() correctly excludes a trailing space from the wrapped line (matching normal word-wrap behaviour) and skips over it as the "space between wrapped words." But when that space is the very last character typed, with no following word yet, there's nothing left to write a following line for — so the cursor position (absoluteCursor) was left unresolved with no line to land on.

The next keystroke then inserted straight onto the end of the now-shorter line (cursor_pos was stale, past the line's actual length), gluing the next word onto the previous one with no space — exactly the "althoughthe" symptom NellowTCS described on the issue.

Generalised the existing empty-paragraph handling (previously gated on currWriteIdx == startLine) to any case where the cursor was never placed, creating or reusing a line for it either way.

How I tested it

Full PM_PRODUCTION build succeeds cleanly (RAM 35.5%, Flash 76.6% — no meaningful size regression). No local unit-test harness exists for this project. I don't have a way to exercise the runtime typing behaviour myself on real hardware — would appreciate a hardware test before merge, same as the pattern that worked well on the earlier #297/#301 exchange.

AI-assisted contribution

Drafted with an AI assistant, reviewed and tested manually.

…raph

Fixes TailsmanDesign#262.

reflowParagraphCore() correctly excludes a trailing space from the
wrapped line (matching normal word-wrap behaviour) and skips over it
as the "space between wrapped words". But when that space is the very
last character typed, with no following word yet, there's nothing
left to write a following line for - so the cursor position
(absoluteCursor) was left unresolved with no line to land on.

The next keystroke then inserted straight onto the end of the
now-shorter line (cursor_pos was stale, past the line's actual
length), gluing the next word onto the previous one with no space -
exactly the "althoughthe" symptom reported on the issue.

Generalised the existing empty-paragraph handling (previously gated
on currWriteIdx == startLine) to any case where the cursor was never
placed, creating or reusing a line for it either way.

Drafted with an AI assistant, reviewed and tested manually.
@NellowTCS NellowTCS added the needs-hw-testing The PR or issue needs hardware testing before merging/closing. label Aug 16, 2026
@NellowTCS NellowTCS added this to the TXT App Overhaul milestone Aug 16, 2026
NellowTCS
NellowTCS previously approved these changes Aug 17, 2026

@NellowTCS NellowTCS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny note, but apart from that it works great on device!

Comment thread Code/PocketMageOS/src/OS_APPS/TXT.cpp Outdated
@NellowTCS
NellowTCS merged commit 6375775 into TailsmanDesign:main Aug 18, 2026
5 checks passed
@NellowTCS NellowTCS removed the needs-hw-testing The PR or issue needs hardware testing before merging/closing. label Aug 18, 2026
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.

Space Doesn't Work for New Line

2 participants