CodeEditApp / CodeEditApp/CodeEditSourceEditor

🐞 Programmatic cursor state updates are never applied

オープン 初心者向け
#377 コメント 1 件 リアクション 0 件 担当者 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start at SourceEditor.updateControllerWithState(_:controller:) and inspect how state.cursorPositions is compared with the controller's current cursor positions. Reproduce the binding update described in the issue, then verify that assigning a different SourceEditorState.cursorPositions value moves the underlying TextViewController cursor.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
swift
領域
desktop
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
84/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。