CodeEditApp / CodeEditApp/CodeEditSourceEditor

🐞 Programmatic cursor state updates are never applied

未關閉 適合新手
#377 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。