Skip to content

fix: text length code cleanup - #135

Merged
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/text-length-code-cleanup
Jul 21, 2026
Merged

fix: text length code cleanup#135
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/text-length-code-cleanup

Conversation

@IvanIhnatsiuk

Copy link
Copy Markdown
Collaborator

Summary

This pull request refactors several classes to consistently use the length() and editableText APIs instead of directly accessing the text property or its length. This improves reliability and clarity, especially when dealing with editable text fields and their spans.

Consistent text length and access handling:

  • Replaced usages of text?.length with length() in EnrichedDragHandler, EnrichedTextInputView, and EnrichedSelection to ensure accurate and null-safe text length retrieval.
  • Updated references from text to editableText when accessing or modifying the text content in CheckListClickHandler and EnrichedTextInputView, ensuring that operations are performed on the editable buffer.

These changes enhance code safety and maintainability by standardizing how text content is accessed and manipulated across the codebase.

Test Plan

Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:

  • Steps to reproduce the bug (if this is a bug fix)
  • Steps to verify the new feature
  • Expected vs actual results
  • Any special conditions or edge cases to test

Screenshots / Videos

Include any visual proof that helps reviewers understand the change — UI updates, bug reproduction or the result of the fix.

Compatibility

OS Implemented
iOS
Android

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request standardizes text access and length calculations across the Android editor implementation by preferring length() and editableText over direct text?.length / text usage, improving consistency when working with editable buffers and spans.

Changes:

  • Replaced several text?.length ?: 0 usages with length() for consistent bounds clamping.
  • Switched span-related operations from text to editableText to ensure operations apply to the editable spannable buffer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt Uses view.length() for selection clamping instead of text?.length.
android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Updates selection clamping and span redraw logic to use length() / editableText.
android/src/main/java/com/swmansion/enriched/EnrichedDragHandler.kt Uses view.length() for pre-drop text length capture.
android/src/main/java/com/swmansion/enriched/CheckListClickHandler.kt Uses editableText as the spannable source for checklist span hit-testing and toggling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IvanIhnatsiuk
IvanIhnatsiuk merged commit 938d0b9 into development Jul 21, 2026
1 check passed
@IvanIhnatsiuk
IvanIhnatsiuk deleted the fix/text-length-code-cleanup branch July 21, 2026 14:11
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.

2 participants