Skip to content

ADFA-2536 Fix text selection in Termux window#885

Merged
hal-eisen-adfa merged 2 commits intostagefrom
ADFA-2536-text-selection-incorrectly-placed-in-the-termux-window
Jan 27, 2026
Merged

ADFA-2536 Fix text selection in Termux window#885
hal-eisen-adfa merged 2 commits intostagefrom
ADFA-2536-text-selection-incorrectly-placed-in-the-termux-window

Conversation

@hal-eisen-adfa
Copy link
Collaborator

Fix gravity for Termux text selection handles
Use already existing coordinates for handles

@hal-eisen-adfa hal-eisen-adfa requested a review from a team January 26, 2026 22:49
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Release Notes: Fix Text Selection in Termux Window

Changes

  • Fixed text selection handle positioning: Updated TextSelectionHandleView.show() to use explicit window coordinates with Gravity.NO_GRAVITY instead of Gravity.CENTER, ensuring selection handles appear at the correct calculated positions rather than being incorrectly centered.

Key Details

  • Modified PopupWindow display call to use pre-calculated window coordinates (coords[0], coords[1]) rather than relying on gravity-based centering with zero offsets
  • Leverages existing coordinate calculations (mPointX, mPointY) and terminal view location data to position handles accurately

Risks & Considerations

  • ⚠️ Behavioral Change: This modifies the visual placement of text selection handles. Thorough testing is recommended to verify handles now appear in the correct positions across different device sizes and orientations
  • ⚠️ Breaking Change Potential: Any downstream code or UX flows that depend on the previous centered behavior may be affected
  • Best Practice: The change improves explicitness by using absolute coordinates instead of gravity-based positioning, making the behavior more predictable and maintainable
  • Consistency: The modification aligns with how coordinates are calculated throughout the class, reducing technical debt

Testing Recommendations

  • Verify text selection handles display correctly on various screen sizes and orientations
  • Test text selection and dragging functionality to ensure handles follow cursor movement properly

Walkthrough

Modified the text selection handle popup positioning strategy in TextSelectionHandleView from center-aligned layout to absolute window coordinates. The handle now displays at explicit screen position coordinates instead of centered relative to the target view.

Changes

Cohort / File(s) Summary
Text Selection Handle Positioning
termux/termux-view/src/main/java/com/termux/view/textselection/TextSelectionHandleView.java
Changed popup positioning from Gravity.CENTER with (0, 0) offset to Gravity.NO_GRAVITY at calculated window coordinates (coords[0], coords[1]), placing the handle at explicit screen coordinates

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A handle that once danced in the center so bright,
Now anchors itself at the coordinates right,
No more centered fuss, just the position we need—
The selection's placed precisely, a rabbit's small deed! 🎯✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly describes the main fix: addressing text selection handle positioning in the Termux window, which aligns with the changeset's modification to TextSelectionHandleView positioning logic.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix involves adjusting gravity and using existing coordinates for handles, which matches the actual code change in TextSelectionHandleView.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hal-eisen-adfa hal-eisen-adfa merged commit e5b3f23 into stage Jan 27, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-2536-text-selection-incorrectly-placed-in-the-termux-window branch January 27, 2026 03:47
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