🐞 Programmatic cursor state updates are never applied

未关闭 适合新手
#377 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
swift
领域
desktop

调研方向

从 SourceEditor.updateControllerWithState(_:controller:) 开始,检查 state.cursorPositions 如何与 controller 当前的光标位置进行比较。重现 issue 中描述的 binding 更新,然后验证为 SourceEditorState.cursorPositions 赋予不同的值会移动底层 TextViewController 的光标。

由索引模型根据 Issue 内容生成。

描述

Description

Programmatic updates to SourceEditorState.cursorPositions are never applied to the underlying TextViewController.

In SourceEditor.updateControllerWithState(_:controller:), the new cursor positions are compared with the same state value:

if let cursorPositions = state.cursorPositions, cursorPositions != state.cursorPositions {
    controller.setCursorPositions(cursorPositions)
}

Because cursorPositions was just unwrapped from state.cursorPositions, the comparison is always false.

To Reproduce
  1. Create a SourceEditor with a binding to SourceEditorState.
  2. After the editor appears, programmatically assign a different value to state.cursorPositions.
  3. Observe that the editor cursor does not move to the requested position.
Expected Behavior

Changing SourceEditorState.cursorPositions should update the cursor positions in the underlying controller.

The comparison likely needs to use the controller's current state:

if let cursorPositions = state.cursorPositions,
   cursorPositions != controller.cursorPositions {
    controller.setCursorPositions(cursorPositions)
}
Version Information

CodeEditSourceEditor: main, revision 1fa4d3c
macOS: 15.7.9
Xcode: 26.3 (17C529)

Additional Context

No matching open or closed issue was found before filing this report.

Screenshots

Not applicable.

主要语言
Swift
星标
720
派生
162
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CodeEditApp/CodeEditSourceEditor 的其他 Issue

查看 CodeEditApp/CodeEditSourceEditor 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。