Skip to content

Fix text editing capabilities#96

Merged
kunitoki merged 3 commits into
mainfrom
dev/text_editor_fixes
May 21, 2026
Merged

Fix text editing capabilities#96
kunitoki merged 3 commits into
mainfrom
dev/text_editor_fixes

Conversation

@kunitoki
Copy link
Copy Markdown
Owner

This pull request significantly improves the handling of empty paragraphs and caret/selection logic in the StyledText class, especially around consecutive newlines and edge cases involving line navigation and caret positioning. It also introduces new APIs for line navigation and value retrieval in result types.

Major improvements include:

StyledText caret and selection improvements

  • Improved caret placement and selection logic for empty paragraphs (consecutive newlines), ensuring correct caret rendering and navigation in these cases, and fixing several bugs related to caret position at the end of text or on empty lines. [1] [2] [3] [4]
  • Refactored getGlyphIndexAtPosition to better handle clicks on empty lines and paragraphs, and to use a more robust line selection algorithm. [1] [2] [3]
  • Added two helper methods, findParagraphNewlinePosition and findParagraphNewlinePositionByIndex, to reliably map between visual lines/paragraphs and character indices for newlines. [1] [2]

New API and navigation features

  • Introduced getGlyphIndexOnAdjacentLine for moving the caret vertically between visual lines, treating soft-wrapped and explicit lines equivalently. [1] [2]
  • Improved initialization and tracking of line heights and paragraph offsets to ensure consistent layout and navigation, especially for empty paragraphs. [1] [2] [3] [4] [5] [6]

ResultValue utility

  • Added valueOr overloads to ResultValue, supporting both copy and move semantics for retrieving the stored value or a default, improving ergonomics when working with result types.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 54.59459% with 168 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.49%. Comparing base (901f930) to head (17417f0).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
modules/yup_gui/widgets/yup_TextEditor.cpp 51.12% 65 Missing ⚠️
modules/yup_graphics/fonts/yup_StyledText.cpp 69.54% 53 Missing ⚠️
modules/yup_gui/native/yup_Windowing_sdl2.cpp 0.00% 41 Missing ⚠️
modules/yup_gui/keyboard/yup_TextInputTarget.cpp 0.00% 6 Missing ⚠️
modules/yup_gui/component/yup_Component.cpp 40.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
+ Coverage   73.17%   73.49%   +0.32%     
==========================================
  Files         573      573              
  Lines       56342    56596     +254     
==========================================
+ Hits        41229    41598     +369     
+ Misses      15113    14998     -115     
Files with missing lines Coverage Δ
modules/yup_core/misc/yup_ResultValue.h 100.00% <100.00%> (ø)
modules/yup_graphics/fonts/yup_StyledText.h 100.00% <ø> (ø)
modules/yup_gui/component/yup_ComponentNative.h 0.00% <ø> (ø)
modules/yup_gui/keyboard/yup_TextInputTarget.h 100.00% <ø> (ø)
...ules/yup_gui/themes/theme_v1/yup_ThemeVersion1.cpp 38.38% <100.00%> (ø)
modules/yup_gui/widgets/yup_TextEditor.h 71.42% <ø> (ø)
modules/yup_gui/component/yup_Component.cpp 58.33% <40.00%> (ø)
modules/yup_gui/keyboard/yup_TextInputTarget.cpp 22.72% <0.00%> (+22.72%) ⬆️
modules/yup_gui/native/yup_Windowing_sdl2.cpp 8.50% <0.00%> (-0.29%) ⬇️
modules/yup_graphics/fonts/yup_StyledText.cpp 77.75% <69.54%> (+10.32%) ⬆️
... and 1 more

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60ba58d...17417f0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunitoki kunitoki merged commit 6b1184d into main May 21, 2026
39 of 40 checks passed
@kunitoki kunitoki deleted the dev/text_editor_fixes branch May 21, 2026 17:01
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