Skip to content

Discard selection history for external edits#1380

Merged
cyanzhong merged 1 commit intomainfrom
develop
Apr 19, 2026
Merged

Discard selection history for external edits#1380
cyanzhong merged 1 commit intomainfrom
develop

Conversation

@cyanzhong
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent restoring stale cursor/selection offsets when a document’s contents are reloaded from disk due to external edits (e.g., via revert), by discarding persisted selection history in those cases.

Changes:

  • Exposes EditorDocument.hasBeenReverted outside the private extension so view controllers can detect recent reverts.
  • Adds EditorSelectionHistory.discard(for:) to centralize removing persisted selection entries.
  • Discards selection history during editor reset when the document was reverted, avoiding stale offsets (especially when file-size checks are skipped).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
MarkEditMac/Sources/Editor/Models/EditorDocument.swift Moves hasBeenReverted to the main class scope so other components can detect reverts.
MarkEditMac/Sources/Editor/EditorSelectionHistory.swift Refactors selection-history removal into a reusable discard(for:) helper.
MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift Discards selection history when resetting the editor after a revert to avoid restoring stale offsets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MarkEditMac/Sources/Editor/Models/EditorDocument.swift
Comment thread MarkEditMac/Sources/Editor/EditorSelectionHistory.swift
@cyanzhong cyanzhong merged commit 46025a9 into main Apr 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants