Skip to content

fix: touch selection auto-scroll in every direction#1914

Merged
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix-touch-selection-horizontal-autoscroll
Feb 28, 2026
Merged

fix: touch selection auto-scroll in every direction#1914
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix-touch-selection-horizontal-autoscroll

Conversation

@bajrangCoder
Copy link
Member

No description provided.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR enhances the touch selection auto-scroll feature by adding support for both horizontal and vertical scrolling during text selection drag operations. Previously, auto-scroll only worked vertically (up/down), which limited usability when selecting text in long lines without line wrapping.

Key Changes

  • New getEdgeScrollDirections helper: Detects which edge(s) (left/right/top/bottom) should trigger scrolling based on pointer position
  • Bidirectional scroll state: Replaced single direction field with separate scrollX and scrollY to track both axes
  • Smart boundary detection: Added #getAutoScrollDelta method that calculates scroll deltas and prevents over-scrolling at content boundaries
  • Line wrapping awareness: Automatically disables horizontal scrolling when line wrapping is enabled (via !this.#view.lineWrapping)
  • Animation frame optimization: Recalculates scroll direction on each frame to handle diagonal movements smoothly

Implementation Quality

The implementation is well-structured with proper boundary checks, clear separation of concerns, and good test coverage. The refactoring maintains backward compatibility while extending functionality cleanly.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The changes are well-tested, logically sound, and enhance existing functionality without breaking changes. The code includes proper boundary validation, respects editor configuration (line wrapping), and adds comprehensive test coverage for the new helper function.
  • No files require special attention

Important Files Changed

Filename Overview
src/cm/touchSelectionMenu.js Upgraded auto-scroll from vertical-only to bidirectional (horizontal + vertical) with proper boundary checking and line-wrapping awareness
src/test/editor.tests.js Added comprehensive test coverage for the new getEdgeScrollDirections helper function, testing all directional combinations

Last reviewed commit: 20e5a85

@bajrangCoder bajrangCoder merged commit 59df8a0 into Acode-Foundation:main Feb 28, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix-touch-selection-horizontal-autoscroll branch February 28, 2026 16:03
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