This repository was archived by the owner on May 29, 2026. It is now read-only.
fix: rerender makes select behavior wrong#179
Open
kamesan012 wants to merge 1 commit into
Open
Conversation
Author
|
@Jocs Hello, please review this code. I'm not sure this will effect other parts. |
Member
|
@kamesan012 Please describe the issue which you want to fix? |
Author
|
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent incorrect selection behavior caused by unnecessary inline re-rendering, primarily by avoiding DOM rewrites when the rendered HTML hasn’t changed and by preserving cursor context during certain updates.
Changes:
- Skip
innerHTMLassignment inInlineRenderer.patchwhen the computed HTML matches the existing DOM. - Pass a cursor into
Format.blurHandler()’supdate()call to better preserve inline rendering behavior around the selection. - Relax
Content.getCursor()’s “selection must be in this block” gating by commenting out theanchorBlock/focusBlockcheck.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/inlineRenderer/index.ts | Avoids rewriting inline HTML when unchanged to reduce selection disruption. |
| packages/core/src/block/base/format.ts | Updates blur re-render flow to optionally supply a cursor to update(). |
| packages/core/src/block/base/content.ts | Changes getCursor() behavior by removing the per-block selection guard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
211
to
224
| const { | ||
| anchor, | ||
| focus, | ||
| anchorBlock, | ||
| focusBlock, | ||
| // anchorBlock, | ||
| // focusBlock, | ||
| isCollapsed, | ||
| isSelectionInSameBlock, // This is always be true. | ||
| direction, | ||
| type, | ||
| } = selection; | ||
|
|
||
| if (anchorBlock !== this || focusBlock !== this) | ||
| return null; | ||
| // if (anchorBlock !== this || focusBlock !== this) | ||
| // return null; | ||
|
|
Comment on lines
337
to
357
| override blurHandler() { | ||
| super.blurHandler(); | ||
| const needRender = this.checkNeedRender(); | ||
| const _cursor = this.getCursor(); | ||
| let cursor = null; | ||
| if (_cursor) { | ||
| const { start, end } = _cursor; | ||
| cursor = { | ||
| path: this.path, | ||
| block: this, | ||
| anchor: { | ||
| offset: start.offset, | ||
| }, | ||
| focus: { | ||
| offset: end.offset, | ||
| }, | ||
| }; | ||
| } | ||
| if (needRender) | ||
| this.update(); | ||
| cursor ? this.update(cursor) : this.update(); | ||
| } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.