Skip to content

fix(editor): improve mixed-language file name display in tabs - #507

Open
JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:master
Open

fix(editor): improve mixed-language file name display in tabs#507
JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:master

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Increase the maximum tab width to avoid squeezing mixed-language names.

增大标签页最大宽度,避免中英文混合文件名被过度挤压。

Log: 优化中英文混合文件名标签显示

PMS: BUG-370145

Influence: 标签页可展示更完整的中英文混合文件名,减少字符显示不清晰问题。

Summary by Sourcery

Increase the maximum tab width in the editor tab bar to allow longer mixed-language file names to be displayed more clearly.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL

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

@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Increases the maximum per-tab width in the editor tab bar so mixed-language (e.g., Chinese/English) filenames are less squeezed and more fully visible.

Flow diagram for updated tab width calculation

flowchart LR
    A[Tabbar::tabSizeHint]
    B[Get total width]
    C[Get tabCount]
    D[Set maxTabWidth = 200]
    E[Set minTabWidth = 110]
    F{tabCount * maxTabWidth <= total?}
    G[tabWidth = maxTabWidth]
    H[tabWidth = total / tabCount]
    I[Return tabWidth]

    A --> B --> C --> D --> E --> F
    F -- Yes --> G --> I
    F -- No --> H --> I
Loading

File-Level Changes

Change Details Files
Increase maximum tab width for editor tabs to show more of mixed-language filenames.
  • Raised the maxTabWidth constant used in tabSizeHint from 160 to 200 so tabs can grow wider when there is enough horizontal space.
  • Kept the minimum tab width and overflow behavior the same, so when tabs overflow they are still evenly distributed as before.
src/controls/tabbar.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@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.

Hey - I've left some high level feedback:

  • Instead of hardcoding maxTabWidth to 200, consider deriving it from font metrics or DPI (or making it a configurable constant) so the tab width scales appropriately across different display settings and localization scenarios.
  • Given the fixed minTabWidth and new maxTabWidth, it may be worth validating that the overflow/auto-resizing logic still behaves well when the window is narrow and many tabs are open, to avoid unexpected layout issues or truncated close icons.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of hardcoding `maxTabWidth` to 200, consider deriving it from font metrics or DPI (or making it a configurable constant) so the tab width scales appropriately across different display settings and localization scenarios.
- Given the fixed `minTabWidth` and new `maxTabWidth`, it may be worth validating that the overflow/auto-resizing logic still behaves well when the window is narrow and many tabs are open, to avoid unexpected layout issues or truncated close icons.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Increase the maximum tab width to avoid squeezing mixed-language names.

增大标签页最大宽度,避免中英文混合文件名被过度挤压。

Log: 优化中英文混合文件名标签显示

PMS: BUG-370145

Influence: 标签页可展示更完整的中英文混合文件名,减少字符显示不清晰问题。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码优化了Tab标签页的宽度计算策略,有效解决了长文件名截断问题并增强了视觉层次
逻辑正确且无安全风险,因未清理原代码中的不可达调试语句扣除5分

■ 【详细分析】

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

tabSizeHint 函数中通过三元表达式 (index == currentIndex()) ? 160 : 110 准确区分了激活与非激活Tab的最小宽度,在 maximumTabSizeHint 函数中同步将最大宽度更新为200,逻辑严密且无误
潜在问题:maximumTabSizeHint 函数中 return 语句之后存在不可达的 qDebug 代码,虽为历史遗留问题,但影响代码严谨性
建议:删除 maximumTabSizeHint 函数末尾不可达的 qDebug() << "Exit maximumTabSizeHint"; 语句

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

修改精准聚焦于核心问题,将最大宽度从160提升至200以容纳更长文件名,同时引入最小宽度差异化处理提升UI体验,配套的单元测试 ut_tabbar.cpp 也同步更新了期望值,保持了测试覆盖率
潜在问题:无
建议:无

  • 3.代码性能(高效)✓

新增的 currentIndex() 调用属于 Qt 框架内部的轻量级索引获取操作,时间复杂度为 O(1),在 UI 布局计算频次下不会产生可感知的性能开销

建议:无

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次变更仅涉及局部整型常量的赋值调整与简单的条件判断,不涉及内存分配、外部输入解析、指针解引用或系统调用,不存在安全攻击面

  • 建议:保持当前的纯计算逻辑,无需额外安全加固

■ 【改进建议代码示例】

diff --git a/src/controls/tabbar.cpp b/src/controls/tabbar.cpp
--- a/src/controls/tabbar.cpp
+++ b/src/controls/tabbar.cpp
@@ -895,11 +895,9 @@ QSize Tabbar::maximumTabSizeHint(int index) const
 {
     qDebug() << "Enter maximumTabSizeHint, index:" << index;
     Q_UNUSED(index)
 #ifdef DTKWIDGET_CLASS_DSizeMode
-    return QSize(160, DGuiApplicationHelper::isCompactMode() ? s_TabbarHeightCompact : s_TabbarHeight);
+    return QSize(200, DGuiApplicationHelper::isCompactMode() ? s_TabbarHeightCompact : s_TabbarHeight);
 #else
-    return QSize(160, 40);
+    return QSize(200, 40);
 #endif
-    qDebug() << "Exit maximumTabSizeHint";
 }

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