Skip to content

fix(editor): improve mobile scrolling, highlighting, and keyboard behavior - #2864

Open
bajrangCoder wants to merge 4 commits into
mainfrom
codemirror-mobile-rendering
Open

fix(editor): improve mobile scrolling, highlighting, and keyboard behavior#2864
bajrangCoder wants to merge 4 commits into
mainfrom
codemirror-mobile-rendering

Conversation

@bajrangCoder

@bajrangCoder bajrangCoder commented Sep 8, 2026

Copy link
Copy Markdown
Member

Fixes: #2318

…avior

- Cache highlighting and preload languages for restored files
- Preserve scroll position through keyboard transitions
- Open the keyboard only for deliberate editing interactions
- Restore native text selection in read-only mode
- Add regression tests and reproducible upstream patches
@bajrangCoder

This comment was marked as outdated.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the mobile CodeMirror experience and vendors the supporting CodeMirror changes.

  • Adds controlled mobile scrolling with bounded rendering and viewport-priority parsing.
  • Adds explicit Android virtual-keyboard handling and caret-reveal behavior.
  • Preserves native selection behavior for read-only editor content.
  • Bounds restored-file language preparation so a stalled provider cannot block startup.
  • Updates vendored CodeMirror sources, generated distributions, patches, packages, tests, and benchmark tooling.

Confidence Score: 5/5

The PR appears safe to merge; both previously reported failures are resolved and no actionable new regression remains.

The restored-file language wait is now bounded without discarding its pending provider, and ambiguous diagonal gestures retain vertical scrolling instead of entering the prior dead zone. Both previous threads are resolved, and the follow-up changes include focused regression coverage.

Important Files Changed

Filename Overview
src/cm/fileLanguage.ts Bounds restored-file language preparation while preserving the pending provider for later editor initialization.
vendor/codemirror-view/src/controlled-scroll.ts Assigns ambiguous diagonal gestures to controlled vertical scrolling while retaining native handling for clearly horizontal swipes.
tests/unit/codemirrorRendering.test.ts Adds regression coverage for diagonal gesture ownership and controlled scrolling.
tests/unit/fileLanguage.test.ts Verifies timeout behavior and safe handling of providers that settle after startup proceeds.
package.json Points CodeMirror dependencies at synchronized vendored packages and adds vendor build and verification commands.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Touch[Mobile touch gesture] --> Classify{Gesture direction}
  Classify -->|Clearly horizontal| NativePan[Native horizontal pan]
  Classify -->|Vertical or ambiguous| ControlledScroll[Controlled vertical scroll]
  ControlledScroll --> BufferedRender[Bounded viewport rendering]

  Restore[Restore foreground file] --> Preload[Start language provider]
  Preload --> Wait{Settles within 250 ms?}
  Wait -->|Yes| OpenHighlighted[Open with prepared language]
  Wait -->|No| OpenText[Open text without blocking]
  OpenText --> LateLanguage[Reuse pending provider when editor initializes]

  EditAction[Explicit editable focus] --> Focus[Focus editor]
  Focus --> ShowIME[Request Android virtual keyboard]
  ShowIME --> Reveal{User browsing viewport?}
  Reveal -->|No| Caret[Reveal caret]
  Reveal -->|Yes| Preserve[Preserve browsed position]
Loading

Reviews (2): Last reviewed commit: "fix(editor): bound startup language wait..." | Re-trigger Greptile

Comment thread src/cm/fileLanguage.ts Outdated
Comment thread vendor/codemirror-view/src/controlled-scroll.ts
- Open restored text after a 250 ms language preparation timeout
- Keep late language loading available for highlighting
- Route near-diagonal swipes to vertical scrolling
- Add regression tests and refresh the vendored CodeMirror patch
@bajrangCoder

This comment was marked as outdated.

@bajrangCoder bajrangCoder added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Sep 8, 2026
@github-actions github-actions Bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Sep 8, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

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

Labels

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

fix/increase text load speed

1 participant