🐞 Programmatic cursor state updates are never applied

Open Beginner friendly
#377 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
swift
Domain
desktop

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Swift
Stars
720
Forks
162
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CodeEditApp/CodeEditSourceEditor

All issues in CodeEditApp/CodeEditSourceEditor

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.