fix(vnote): keep ctrl multi-selection count in sync#406
Conversation
Update selected note indexes before selectSize on Ctrl+click so onSelectSizeChanged reads the latest selection and multi-choice count matches highlighted items. Ctrl+点击多选时先更新 selectedNoteItem,再同步 selectSize, 避免 onSelectSizeChanged 读取旧选中状态导致右侧统计数量错误。 Log: 修复Ctrl多选笔记后右侧统计数量与实际选中数量不一致 PMS: BUG-369995 Influence: Ctrl多选和取消选中时,左侧列表选中状态与右侧多选统计保持一致。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideSynchronizes the multi-selection count with the actual selected notes when using Ctrl+click in the note list, ensuring the right-side multi-select statistics stay consistent with the highlighted items. Sequence diagram for Ctrl+click multi-selection count syncsequenceDiagram
actor User
participant ItemListView
participant validSelectedNoteIndexes
participant StatsPanel
User->>ItemListView: Ctrl_click(index)
ItemListView->>ItemListView: selectedNoteItem.slice()
ItemListView->>ItemListView: splice_or_push_index
ItemListView->>validSelectedNoteIndexes: validSelectedNoteIndexes()
validSelectedNoteIndexes-->>ItemListView: selectedIndexes
ItemListView->>ItemListView: selectSize = selectedIndexes.length
ItemListView->>StatsPanel: onSelectSizeChanged(selectSize)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that
selectSizeis derived fromvalidSelectedNoteIndexes().length, consider removing any other code paths that manually increment/decrementselectSizeso it is consistently treated as a derived value from the selected indexes. - If
validSelectedNoteIndexes()is non-trivial, you might want to cache or centralize the selection update logic so that recalculatingselectSizeon every Ctrl-click does not duplicate work or introduce subtle inconsistencies elsewhere.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that `selectSize` is derived from `validSelectedNoteIndexes().length`, consider removing any other code paths that manually increment/decrement `selectSize` so it is consistently treated as a derived value from the selected indexes.
- If `validSelectedNoteIndexes()` is non-trivial, you might want to cache or centralize the selection update logic so that recalculating `selectSize` on every Ctrl-click does not duplicate work or introduce subtle inconsistencies elsewhere.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已修复原有逻辑缺陷,无需进一步修改。保持现有实现即可。
case Qt.ControlModifier:
var nextSelection = selectedNoteItem.slice();
var pos = nextSelection.indexOf(index);
if (pos != -1)
nextSelection.splice(pos, 1);
else
nextSelection.push(index);
selectedNoteItem = nextSelection;
selectSize = validSelectedNoteIndexes().length;
break; |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
|
/forcemerge |
Update selected note indexes before selectSize on Ctrl+click so onSelectSizeChanged reads the latest selection and multi-choice count matches highlighted items.
Ctrl+点击多选时先更新 selectedNoteItem,再同步 selectSize,
避免 onSelectSizeChanged 读取旧选中状态导致右侧统计数量错误。
Log: 修复Ctrl多选笔记后右侧统计数量与实际选中数量不一致
PMS: BUG-369995
Influence: Ctrl多选和取消选中时,左侧列表选中状态与右侧多选统计保持一致。
Summary by Sourcery
Bug Fixes: