Skip to content

Discard selection history when file size changes#1378

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

Discard selection history when file size changes#1378
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

Adds a content-length check to invalidate stored selection history when a file’s size changes (likely due to external edits), preventing restoring stale selections.

Changes:

  • Persist a per-file content length alongside saved selection ranges and invalidate history when the length differs on restore.
  • Extend the bridge LineColumnInfo payload to include contentLength (CodeMirror doc length).
  • Update editor reset/restore flow to pass a length value (skipping the check for CR/CRLF-normalized content).

Reviewed changes

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

Show a summary per file
File Description
MarkEditMac/Sources/Editor/EditorSelectionHistory.swift Stores file content length with selection history; discards entries when length mismatches.
MarkEditMac/Sources/Editor/EditorHistoryStorage.swift Extends persisted SelectionRangeEntry with a fileSize (content length) field.
MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift Supplies content length (or nil for non-LF content) when restoring selection.
MarkEditKit/Sources/Bridge/Native/Generated/NativeModuleCore.swift Adds contentLength to LineColumnInfo used by the native bridge.
CoreEditor/src/modules/selection/types.ts Extends LineColumnInfo type with contentLength.
CoreEditor/src/modules/selection/selectedLineColumn.ts Populates contentLength from state.doc.length.

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

Comment thread MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift
Comment thread MarkEditMac/Sources/Editor/EditorHistoryStorage.swift
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

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.


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

@cyanzhong cyanzhong merged commit 2271c4d into main Apr 19, 2026
5 checks 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