chaitin / chaitin/MonkeyCode

输入全角字符后光标位置偏移约 1 个全角字符

Open
#1,224 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.7k
Forks
719
Avg merge
4h 30m
Merged PRs (30d)
83

Description

问题描述

在 MonkeyCode 客户端对话框输入全角字符后,输入框内的文字排版会出现异常,光标在移动时光标渲染位置会比真实插入点偏右约 1 个全角字符,且随着输入内容变化会产生明显错位。全角/中文越多,越容易触发。

复现步骤

  1. 打开 MonkeyCode 客户端的任务对话输入框
  2. 输入全角字符,如:中文测试文本
  3. 在已有全角内容后继续输入,或使用左右方向键移动光标
  4. 观察光标位置会偏离真实插入点,约偏移 1 个全角字符宽度

预期行为

光标位置应与实际插入点严格对齐,中文/全角字符输入时光标不应发生额外偏移。

实际表现

光标视觉位置向右偏移约 1 个全角字符宽度,尤其在行尾、回车前、全角文本后最为明显。

环境信息

  • 客户端:MonkeyCode Desktop
  • 系统:macOS
  • 前端定位:frontend/src/components/console/task/chat-inputbox.tsx
  • 疑似相关样式:field-sizing:content

初步排查

从源码看,聊天输入框的 textarea 显式使用了:

[field-sizing:content]

怀疑该属性在全角字符场景下,浏览器对 textarea 的光标/选区渲染位置计算存在偏差,导致视觉偏移约一个全角字符。建议优先验证此处与 CJK 排版行为的兼容性。

建议修复方向

  • 优先评估去除输入框的 field-sizing:content 是否能缓解问题
  • 若仍需自动高度,可改用 JS 监听 input/scrollHeight 手动调整高度
  • 补充全角文本输入/光标移动的回归测试,防止后续再回退
Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in frontend/src/components/console/task/chat-inputbox.tsx and inspect the textarea's field-sizing:content usage. Reproduce the issue with 中文测试文本, including cursor movement and input near the line end, then verify that the rendered cursor aligns with the insertion point for full-width text and that automatic sizing still behaves as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.