[mac] fix: double-click in Preview no longer switches to Edit mode#369
Merged
Conversation
The `jumpToSource` thread (JS dblclick listener → WKScriptMessageHandler → `onJumpToSource` closure) was set up so any double-click on rendered markdown both scrolled the editor and flipped `viewMode = .edit`. This hijacked every double-click word selection in Preview. Removing the whole thread (listener, message handler, callback, and the now-unused `scrollEditorToLine` notification + EditorView observer) restores normal selection and keeps Preview mode sticky. Fixes #366
Deploying clearly with
|
| Latest commit: |
e73329c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://caef1a42.clearly-cjz.pages.dev |
| Branch Preview URL: | https://claude-beautiful-morse-d14c3.clearly-cjz.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #366. Double-clicking any rendered text in Preview mode was kicking the user back into the editor — including when they were just trying to select a word.
Root cause: a JS
dblclicklistener on the WKWebView posted ajumpToSourcemessage to a Swift handler that both scrolled the editor and setviewMode = .edit. Since virtually every rendered element carries adata-sourcepos, every word-select triggered it.This PR removes the entire jump-to-source thread end-to-end — no producer, no consumer, no notification. Double-click in Preview now does what
WKWebViewdoes natively (select the word) and stays in Preview.Changes
dblclicklistener from the preview HTMLjumpToSourceWKScriptMessageHandler registration, dispatch, and cleanuponJumpToSourcefromPreviewViewand itsCoordinatoronJumpToSource:closure passed byContentViewscrollEditorToLinenotification declaration, theEditorViewobserver, andhandleScrollToLine(their only producer was the closure above)Net: -67 lines, no new code.
iOS is unaffected — it never had this listener.
Test plan