Skip to content

master#304

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
Johnson-zs:master
Jun 17, 2026
Merged

master#304
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
Johnson-zs:master

Conversation

@Johnson-zs

Copy link
Copy Markdown
Contributor
  • feat: add configurable keyword positioning in search results
  • chore: bump version to 1.3.59

1. Added positioningMaxLength parameter to HighlightOptions structure to
allow configuration of keyword positioning window size
2. Modified customHighlight function to accept and use this parameter
for better keyword positioning in search results
3. Enforced minimum window size of 30 characters for proper keyword
visibility
4. Updated all function calls to pass the new parameter
5. Improved documentation for the customHighlight function parameters

Log: Added configurable keyword positioning window for better search
result snippets

Influence:
1. Test search results with different positioningMaxLength values (below
30 and above 30)
2. Verify keyword visibility and snippet positioning in results
3. Check HTML highlighting still works when enabled
4. Test with both short and long content samples
5. Verify behavior with empty content or keyword lists

feat: 添加可配置的关键词定位功能

1. 在HighlightOptions结构中添加positioningMaxLength参数,用于配置关键词
定位窗口大小
2. 修改customHighlight函数以接受并使用此参数,改进搜索结果中的关键词定位
3. 强制30个字符的最小窗口尺寸以确保关键词可见性
4. 更新所有函数调用以传递新参数
5. 改进了customHighlight函数的参数文档

Log: 新增可配置关键词定位窗口,改进搜索结果片段显示

Influence:
1. 使用不同的positioningMaxLength值测试搜索结果(小于30和大于30)
2. 验证结果中的关键词可见性和片段定位
3. 检查启用HTML高亮时是否仍正常工作
4. 测试短内容和长内容样本
5. 验证空内容或关键词列表时的行为

Fixes: #365083

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 1.3.59
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码完美实现了关键词定位窗口的可配置化,逻辑严密且无任何安全风险
代码逻辑正确、质量良好、无性能损耗且无安全漏洞,符合满分标准

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

函数声明与定义的参数默认值设置符合C++标准,仅在头文件声明处提供默认值。使用qMax(30, positioningMaxLength)有效防止了非法或过小的参数值干扰后续的字符串截取与定位逻辑,保障了边界条件下的健壮性。

  • 2.代码质量(良好)✓

新增字段命名清晰,使用effectivePositioningLength区分传入参数与实际生效值,增强了代码可读性。同步更新了头文件中的Doxygen注释,保持了文档与代码的一致性,结构体成员对齐规范。

  • 3.代码性能(无性能问题)✓

qMax宏在编译期展开或内联,运行时无额外函数调用开销。参数透传过程仅涉及寄存器或栈上的整型值拷贝,对整体搜索高亮性能无任何负面影响。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码未引入任何外部输入执行、内存越界或注入风险。通过qMax限制最小值,有效防止了因外部配置错误导致的潜在数组越界或死循环等异常,属于良好的防御性编程实践。

  • 建议:保持现有的防御性编程风格,后续新增可配置项时同样考虑下限与上限的边界保护。

■ 【改进建议代码示例】

// 当前代码已足够优秀,无需额外修改,此处展示保持当前良好实践的代码结构
struct HighlightOptions
{
    int maxPreviewLength = 200;      ///< Maximum snippet length in characters
    int positioningMaxLength = 30;   ///< Keyword positioning window size (min 30)
    bool enableHtml = false;         ///< Wrap matched keywords with <b> tags
};

QString customHighlight(const QStringList &keywords, const QString &content, int maxLength, bool enableHtml, int positioningMaxLength)
{
    if (content.isEmpty() || keywords.isEmpty()) {
        return QString();
    }
    
    // Enforce minimum of 30 for the positioning window
    const int effectivePositioningLength = qMax(30, positioningMaxLength);
    
    int optimalStart = findOptimalStartPosition(content, match.position, effectivePositioningLength);
    
    // ... 后续使用 effectivePositioningLength 进行安全计算 ...
}

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit b05f457 into linuxdeepin:master Jun 17, 2026
41 checks passed
@deepin-bot

deepin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

TAG Bot

Tag created successfully

📋 Tag Details
  • Tag Name: 1.3.59
  • Tag SHA: bd0957b098b44fe9b25dc1f189040f20a1ba213a
  • Commit SHA: b05f4573f5d37df0ad755674a87b2dd5ce97c216
  • Tag Message:
    Release util-dfm 1.3.59
    
    
  • Tagger:
    • Name: Johnson-zs
  • Distribution: unstable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants