fix(live-preview): use live doc content for table column/row operations#156
Open
zhenyu666-debug wants to merge 1 commit into
Open
fix(live-preview): use live doc content for table column/row operations#156zhenyu666-debug wants to merge 1 commit into
zhenyu666-debug wants to merge 1 commit into
Conversation
|
|
01ad993 to
53bc801
Compare
Author
|
/cla check |
1 similar comment
Author
|
/cla check |
7581ba4 to
68063f8
Compare
Author
|
/cla check |
1 similar comment
Author
|
/cla check |
Co-authored-by: Cursor <cursoragent@cursor.com>
68063f8 to
8548da6
Compare
Author
|
/cla check |
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.
fix(live-preview): use live doc content for table column/row operations
Summary / 摘要
When adding or deleting columns/rows in a table, the operation now reads
cell content from the live editor document instead of the stale widget
snapshot. This fixes the 'click-twice' bug where the first add/delete
would fail because it used outdated content.
对表格进行添加或删除行列操作时,现在从实时编辑器文档读取单元格内容,
而不是过时的 widget 快照。这修复了"点击两次"的 bug——第一次操作会失败,
因为使用的是过期内容。
Motivation / 背景与动机
When a user clicks to add a column or delete a row in a table cell that
has pending uncommitted edits (IME input, selection, etc.), the widget
snapshot used for computing new cell content was stale. Two scenarios:
用户点击添加列或删除行时,如果单元格有未提交的编辑(输入法输入、选区等),
widget 快照用于计算新单元格内容时已经过期。两种场景:
Changes / 变更内容
Rebased to single commit — previous 8 commits reverted and rebuilt as one clean commit.
packages/core:live-preview-table.ts: range detection rewritten to walkdoc.lineAt()boundariesinstead of guessing via
this.source.length + 512. Prevents eating trailingparagraphs and missing rows on long tables.
live-preview-table.ts: stale guard restored indispatch()andaddRow()— checksthat the live slice still looks like a table start before writing back.
live-preview-table.ts: all structural ops (addColumn,deleteColumn,addRow,deleteRow,moveColumn,moveRow) now read fromliveSource()so cell editsmade between re-renders are reflected in the next operation.
packages/core/test/live-preview-table-ops.test.ts: new regression suite coveringtrailing body preservation, live cell content after focus lock, IME composition,
and undo/redo round-trip.
packages/plugin-*: no changesapps/electron-demo: no changesTesting / 测试
pnpm testpasses / 全绿pnpm build) / 受影响包构建通过packages/core/test/live-preview-table-ops.test.ts— 5 regression scenarios:Compliance / 合规自检
dist/,dist-electron/, compiled.jsfrom.ts) / 未提交构建产物.env/ personal vault data committed / 无敏感信息Checklist / 自检清单
live-preview-table.ts→ walked through the 12 Table Widget rules in CLAUDE.md /