Skip to content

Add active_cursor_position to CodeEditorView for IME positioning#9555

Merged
kevinyang372 merged 3 commits intowarpdotdev:masterfrom
qubaitian:feat/add-active-cursor-position-for-ime
May 2, 2026
Merged

Add active_cursor_position to CodeEditorView for IME positioning#9555
kevinyang372 merged 3 commits intowarpdotdev:masterfrom
qubaitian:feat/add-active-cursor-position-for-ime

Conversation

@qubaitian
Copy link
Copy Markdown
Contributor

Description

  • Fixes IME candidate window positioning for the code editor on macOS.
  • CodeEditorView now provides active_cursor_position() so the IME anchor can be derived from the code editor caret instead of falling back to stale positions from other inputs (e.g. terminal input).
  • Uses current-frame caret geometry with a last-frame fallback to keep placement stable during fast composition/layout timing.

Testing

  • Manual (macOS):
    • Opened a workspace with both a terminal pane and a code editor pane.
    • Typed with Chinese IME in terminal first (candidate popup follows terminal caret).
    • Switched to code editor and typed with IME; verified candidate popup now anchors near the code editor caret instead of staying at terminal coordinates.
    • Repeated with mouse selection/caret moves in the code editor; verified IME popup remains correctly anchored in editor context.
  • Automated:
    • Ran cargo check -p warpui --lib locally after changes.

No new automated tests were added because this bug is tied to macOS IME runtime behavior and AppKit caret query timing (firstRectForCharacterRange) that is difficult to reliably simulate in existing unit/integration test harnesses.

Server API dependencies

  • Is this change necessary to make the client compatible with a desired server API breaking change?
  • Does this change rely on a new server API?
    • If so, is the use of this API restricted to client channels that rely on the staging server (e.g. WarpDev)?
  • Is this change enabling the use of a server API on client channels that rely on the production server (e.g. WarpStable)?
    • If so, has the new server API been stable on production for at least one server release cycle? See here for more details.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Changelog Entries for Stable

CHANGELOG-NEW-FEATURE: {{text goes here...}}
CHANGELOG-IMPROVEMENT:
CHANGELOG-BUG-FIX: Fix macOS IME candidate popup positioning in code editor panes so it anchors to the editor caret instead of stale terminal/input positions.
CHANGELOG-BUG-FIX:
CHANGELOG-IMAGE: {{GCP-hosted URL goes here...}}
CHANGELOG-OZ: {{text goes here...}}

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @qubaitian on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 30, 2026

@qubaitian

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @kevinyang372.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@qubaitian
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @qubaitian on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

The cla-bot has been summoned, and re-checked this pull request!

@qubaitian
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @qubaitian on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

The cla-bot has been summoned, and re-checked this pull request!

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds CodeEditorView::active_cursor_position so macOS IME positioning can query the focused code editor caret using the rich-text render state's saved cursor position.

Concerns

  • No blocking correctness, security, or performance concerns found in the changed hunk.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@qubaitian
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@oz-for-oss oz-for-oss Bot requested a review from kevinyang372 April 30, 2026 07:07
@cla-bot cla-bot Bot added the cla-signed label Apr 30, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

The cla-bot has been summoned, and re-checked this pull request!

@captainsafia captainsafia added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Apr 30, 2026 — with Warp Dev Github Integration
@qubaitian
Copy link
Copy Markdown
Contributor Author

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 1, 2026

@qubaitian

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 1, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR wires CodeEditorView into WarpUI active cursor position reporting so macOS IME anchoring can use the code-editor caret.

Concerns

  • UI-impacting behavior changes need visual evidence. The PR description includes manual testing notes but no screenshot or video; for faster review, please upload screenshots or a video of the IME candidate popup anchoring to the code editor caret end to end.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Member

@kevinyang372 kevinyang372 left a comment

Choose a reason for hiding this comment

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

This worked great! I have one comment on the font size

Comment thread app/src/code/editor/view.rs Outdated
fn active_cursor_position(&self, ctx: &ViewContext<Self>) -> Option<CursorInfo> {
let render_state = self.model.as_ref(ctx).render_state().as_ref(ctx);
let cursor_id = render_state.saved_positions().cursor_id();
let font_size = Appearance::as_ref(ctx).monospace_font_size();
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.

Instead of hard-coding monospace font here, can we use RenderState::styles::base_text::font_size instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — switched to render_state.styles().base_text.font_size.

@kevinyang372
Copy link
Copy Markdown
Member

@qubaitian Mind running cargo fmt and re-push? I can merge this after that

@qubaitian
Copy link
Copy Markdown
Contributor Author

qubaitian commented May 2, 2026

@kevinyang372 Done — ran cargo fmt and pushed.

@kevinyang372 kevinyang372 merged commit 75bddcc into warpdotdev:master May 2, 2026
22 checks passed
zerx-lab pushed a commit to zerx-lab/warp that referenced this pull request May 3, 2026
…pdotdev#9555)

## Description
<!-- Please remember to add your design buddy onto the PR for review, if
it contains any UI changes! -->
- Fixes IME candidate window positioning for the code editor on macOS.
- `CodeEditorView` now provides `active_cursor_position()` so the IME
anchor can be derived from the code editor caret instead of falling back
to stale positions from other inputs (e.g. terminal input).
- Uses current-frame caret geometry with a last-frame fallback to keep
placement stable during fast composition/layout timing.

## Testing
<!--
How did you test this change? What automated tests did you add? If you
didn't add any new tests, what's your justification for not adding any?

If you're not sure whether you should add a test, check our testing
policy:
https://www.notion.so/warpdev/How-We-Code-at-Warp-257fe43d556e4b3c8dfd42f70004cc72#1f97825450504baa9c5fd87a737daa09
-->
- Manual (macOS):
  - Opened a workspace with both a terminal pane and a code editor pane.
- Typed with Chinese IME in terminal first (candidate popup follows
terminal caret).
- Switched to code editor and typed with IME; verified candidate popup
now anchors near the code editor caret instead of staying at terminal
coordinates.
- Repeated with mouse selection/caret moves in the code editor; verified
IME popup remains correctly anchored in editor context.
- Automated:
  - Ran `cargo check -p warpui --lib` locally after changes.

No new automated tests were added because this bug is tied to macOS IME
runtime behavior and AppKit caret query timing
(`firstRectForCharacterRange`) that is difficult to reliably simulate in
existing unit/integration test harnesses.

## Server API dependencies
<!-- You may remove this section if your PR does not have any server
dependencies. -->
- [ ] Is this change necessary to make the client compatible with a
desired [server API breaking
change](https://www.notion.so/warpdev/How-to-safely-introduce-server-API-breaking-changes-0aa805ff5d5d41fd8834f3c95caba0b4?pvs=4#d55ecf8aea3449949d3c33b0e67f6800)?
- [ ] Does this change rely on a [new server
API](https://www.notion.so/warpdev/How-to-add-a-new-full-stack-feature-8412cede405a4ec194b32bdd4b951035?pvs=4#04da1e6a493542d68b3e998c7d339640)?
- [ ] If so, is the use of this API restricted to client channels that
rely on the staging server (e.g. WarpDev)?
- [ ] Is this change enabling the use of a server API on client channels
that rely on the production server (e.g. WarpStable)?
- [ ] If so, has the new server API been stable on production for at
least one server release cycle? See
[here](https://www.notion.so/warpdev/How-to-add-a-new-full-stack-feature-8412cede405a4ec194b32bdd4b951035?pvs=4#73b202f939834b97ab1fbdf7fc82cd53)
for more details.

## Agent Mode
- [ ] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

## Changelog Entries for Stable
<!--
The entries below will be used when constructing a soft-copy of the
stable release changelog. Leave blank or remove the lines if no entry in
the stable changelog is needed. Entries should be on the same line,
without the `{{` `}}` brackets. You can use multiple lines, even of the
same type. The valid suffixes are:

* NEW-FEATURE: for new, relatively sizable features. Features listed
here will likely have docs / social media posts / marketing launches
associated with them, so use sparingly.
* IMPROVEMENT: for new functionality of existing features.
* BUG-FIX: for fixes related to known bugs or regressions.
* IMAGE: the image specified by the URL (hosted on GCP) will be added to
Dev & Preview releases. For Stable releases, see the pinned doc in the
#release Slack channel.
* OZ: Oz-related updates. Use `CHANGELOG-OZ`. At most 4 Oz updates are
shown in-app per release.
-->

CHANGELOG-NEW-FEATURE: {{text goes here...}}
CHANGELOG-IMPROVEMENT: 
CHANGELOG-BUG-FIX: Fix macOS IME candidate popup positioning in code
editor panes so it anchors to the editor caret instead of stale
terminal/input positions.
CHANGELOG-BUG-FIX: 
CHANGELOG-IMAGE: {{GCP-hosted URL goes here...}}
CHANGELOG-OZ: {{text goes here...}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants