CodeEditApp / CodeEditApp/CodeEditSourceEditor
🐞 Programmatic cursor state updates are never applied
- 主要语言
- Swift
- 星标
- 719
- 派生
- 160
- PR 合并指标
- 30 天内没有已合并 PR
描述
### 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:
```swift
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:
```swift
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.
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 SourceEditor.updateControllerWithState(_:controller:) 开始,检查 state.cursorPositions 如何与 controller 当前的光标位置进行比较。重现 issue 中描述的 binding 更新,然后验证为 SourceEditorState.cursorPositions 赋予不同的值会移动底层 TextViewController 的光标。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- swift
- 领域
- desktop
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 84/100