CodeEditApp / CodeEditApp/CodeEditSourceEditor

🐞 Programmatic cursor state updates are never applied

Đang mở Phù hợp với người mới
#377 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Swift
Star
719
Fork
160
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
swift
Lĩnh vực
desktop
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
84/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.