fix(editor): record undo snapshot on mouseup to preserve cursor position#351
Merged
deepin-bot[bot] merged 1 commit intoJun 1, 2026
Conversation
The undo system's lazy snapshot mechanism did not capture cursor position when user clicked to move it, causing cursor to jump to a stale position after Ctrl+Z. 修复编辑器撤销时光标跳转到错误位置的问题,在mouseup时记录快照 以保存正确的光标位置。 Log: 修复撤销时光标位置跳转错误 PMS: BUG-332099 Influence: 用户点击移动光标后输入内容再撤销,光标现在会正确地 保持在点击位置,而不是跳转到之前的旧位置。
lzwind
approved these changes
Jun 1, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Note
详情{
"src/web/js/summernote_v9_2.js": [
{
"line": " var KEY_BOGUS = 'bogus';",
"line_number": 3933,
"rule": "S106",
"reason": "Var naming | 6d7db7168d"
},
{
"line": " .attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/')",
"line_number": 6881,
"rule": "S35",
"reason": "Url link | dcb31e9ddf"
},
{
"line": " .attr('src', 'http://v.qq.com/iframe/player.html?vid=' + vid + '&auto=0');",
"line_number": 6918,
"rule": "S35",
"reason": "Url link | ce631f8419"
}
]
} |
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已仔细审查了你提供的 Git Diff 输入。这段代码主要是在 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的详细审查意见与改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
💡 改进建议代码基于以上分析,如果你确实需要在 }).on('mouseup', function (event) {
// 使用现代标准 event.button 替代已废弃的 event.which (2 代表右键)
if (event.button !== 2) {
_this.context.triggerEvent('mouseup', event);
// 记录撤销前保存当前内容快照,用于比对
var currentContent = _this.editable.html();
// 建议增加脏检查:只有内容确实发生变化时才记录撤销
// 假设 _this.lastUndoSnapshot 是你维护的上一次记录时的内容
if (currentContent !== _this.lastUndoSnapshot) {
_this.history.recordUndo();
_this.lastUndoSnapshot = currentContent; // 更新快照
}
}
}).on('scroll', function (event) {
_this.context.triggerEvent('scroll', event);最后确认:Summernote 原生代码中通常已经在 |
Contributor
Author
|
/merge |
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.
The undo system's lazy snapshot mechanism did not capture cursor position when user clicked to move it, causing cursor to jump to a stale position after Ctrl+Z.
修复编辑器撤销时光标跳转到错误位置的问题,在mouseup时记录快照
以保存正确的光标位置。
Log: 修复撤销时光标位置跳转错误
PMS: BUG-332099
Influence: 用户点击移动光标后输入内容再撤销,光标现在会正确地
保持在点击位置,而不是跳转到之前的旧位置。