Skip to content

feat: add pinch-to-zoom support to editor - #2963

Open
gahanad wants to merge 6 commits into
Acode-Foundation:mainfrom
gahanad:feat/editor-pinch-to-zoom
Open

gahanad wants to merge 6 commits into
Acode-Foundation:mainfrom
gahanad:feat/editor-pinch-to-zoom

Conversation

@gahanad

@gahanad gahanad commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds pinch-to-zoom support to the editor to make editing more convenient on mobile devices.

Users can adjust the editor's font size using a two-finger pinch gesture, improving readability and usability on smaller screens.

Changes Made

  • Added a pinch-to-zoom extension for the editor.
  • Dynamically adjusts the editor font size based on the pinch gesture.
  • Enforces minimum and maximum font-size limits.
  • Saves the updated font size setting when the gesture ends.
  • Cleans up touch event listeners when the extension is destroyed.
  • Added unit tests covering pinch-zoom behavior and font-size calculations.

Testing

  • Added unit tests for pinch-zoom functionality.
  • Verified the targeted unit tests pass.
  • Manually tested pinch-to-zoom on an Android device.
  • Verified the full test suite and CI checks.

Related Issue

Closes #2426

@github-actions github-actions Bot added the enhancement New feature or request label Oct 9, 2026
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both numbered previous findings are fixed.

Summary

Adds two-finger pinch zoom to the editor, with bounded font sizes, live previews, and saving when the gesture ends.

  • You can pinch the editor text to change its font size.
  • Two-finger gestures cancel pending text-selection actions.

Reviews (6) · Last reviewed commit: "Fixed corrections for pinchZoom" · Reviewed by Greptile

Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
@gahanad

This comment was marked as outdated.

Comment thread src/cm/pinchZoom.ts Outdated
@gahanad

This comment was marked as outdated.

Comment thread src/cm/pinchZoom.ts Outdated
@gahanad

This comment was marked as outdated.

@bajrangCoder

bajrangCoder commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

There several accidental zoom in/zoom out

screen-20261011-164227.mp4

Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/pinchZoom.ts Outdated
Comment thread src/cm/mainEditorExtensions.ts Outdated
@gahanad

This comment was marked as outdated.

Comment thread src/cm/pinchZoom.ts
Comment thread src/cm/touchSelectionMenu.js Outdated
@gahanad

gahanad commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@greptile

@gahanad
gahanad requested a review from bajrangCoder October 13, 2026 21:32
Comment thread src/cm/pinchZoom.ts
persistFontSize();
}

const target = view.contentDOM;

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.

Touch events keep targeting the element where each finger first landed, even after that element is removed from the DOM. Since move/end/cancel are only listened for on contentDOM, the gesture can get stuck:

  1. Two fingers start on lines in the lower part of the editor; spread to ~2x.
  2. The preview font change + requestMeasure() makes CM recompute a smaller viewport (visible area + ~500px margin), and the .cm-line under a finger is unmounted.
  3. That finger's touchmove/touchend now dispatch to a detached node and never reach contentDOM.

Result: gesture.pinching stays true, the inline preview is never cleared or persisted, and every subsequent two-finger touchstart bails on if (gesture.pinching ...) — pinch is dead until the editor state is swapped.

Suggest attaching the move/end/cancel listeners to window/document (capture) when a pinch starts and removing them in endPinch/destroy.

@bajrangCoder

Copy link
Copy Markdown
Member

Also isn't the line number area and editor area pinch-to-zoom at same time for better and smooth feel? as currently line number area adjusted itself after leaving zoom.

Also in some cases some accidental scrolls maybe using three finger/two finger etc does nothing but normally in acode those just scrolls so removing that will be a bit weird(if there is no valid reason)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Request featured "Zoom"

3 participants