🐞 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 摘要。