Repository navigation
fix: 等长替换块按位置配对,恢复整段改写的行内高亮 - #10
Merged
Merged
Conversation
- 删增行数相等时按位置配对,不再因相似度低于 0.5 放弃配对 - 行数不等且一行都没配上时回退按位置配对,整块重写也能显示行内高亮 - 等长块同样受字符总量上限约束,避免极端规模阻塞渲染 - 版本升到 0.4.5,README 更新替换配对说明
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.
问题
整段中文改写会被判成「不相似」,删除行与新增行都拿不到行内下划线,展开后只剩一片红绿底色,与内置卡片没有区别。
一段中文长句整体重写就是这种情况:同一位置的两行只保留少量词句,其余全被替换,公共前后缀占比只有百分之几,过不了 0.5 的相似度门槛。
原因
#9 给
alignBlock加了相似度筛选:lineSimilarity只统计公共前后缀占较长行的比例,低于MIN_PAIR_SIMILARITY就不配对。两侧各只有一行时,唯一能配的一行被丢弃,高亮区间为空,字符级 diff 整个消失。改动
MAX_ALIGN_CHARS约束,防止超大替换块逐行跑字符 diff。验证
pnpm typecheck与pnpm build通过。