Skip to content

fix: preserve keyboard operators during input cleanup#206

Merged
lzwind merged 1 commit into
linuxdeepin:masterfrom
JWWTSL:master
Jul 10, 2026
Merged

fix: preserve keyboard operators during input cleanup#206
lzwind merged 1 commit into
linuxdeepin:masterfrom
JWWTSL:master

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Normalize keyboard operators before separator formatting so transient ASCII operators are not dropped during text cleanup.

Keep the current operator when applying point fault tolerance to the right side of an expression.

Summary by Sourcery

Preserve keyboard-entered arithmetic operators during input normalization and point fault tolerance so expressions retain their intended operators.

Bug Fixes:

  • Ensure transient ASCII arithmetic operators are converted to normalized symbols before separator formatting to prevent them being dropped during text cleanup.
  • Maintain the operator character when applying point fault tolerance by only fault-tolerancing the left and right operands around it.

Enhancements:

  • Allow both normalized and ASCII arithmetic operators in the set of permitted input characters to better support different keyboard layouts.

@sourcery-ai

sourcery-ai Bot commented Jul 10, 2026

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

Reviewer's Guide

This PR adjusts input normalization and fault-tolerance logic so keyboard-entered ASCII and full‑width operators are preserved and normalized consistently, and point fault tolerance on expressions does not overwrite the operator at the split point.

Sequence diagram for updated input normalization and point fault tolerance

sequenceDiagram
  actor User
  participant InputEdit
  participant ExpressionBar

  User->>InputEdit: handleTextChanged(text)
  InputEdit->>InputEdit: normalize decimal separator
  InputEdit->>InputEdit: replace ASCII/fullwidth operators
  InputEdit->>InputEdit: filter with allowedStatic

  User->>ExpressionBar: pointFaultTolerance(text)
  ExpressionBar->>ExpressionBar: split leftitem, rightitem at operator
  ExpressionBar->>InputEdit: symbolFaultTolerance(leftitem)
  ExpressionBar->>ExpressionBar: replace left side
  ExpressionBar->>InputEdit: symbolFaultTolerance(rightitem)
  ExpressionBar->>ExpressionBar: replace right side [operator preserved]
  ExpressionBar-->>User: result
Loading

File-Level Changes

Change Details Files
Normalize keyboard and full-width operators earlier in the text-change pipeline and expand the set of allowed operator characters so transient ASCII operators are not dropped during cleanup.
  • Add an initial normalization step on the raw expression string to convert ASCII and full-width operators and parentheses to their canonical internal forms before logging and further processing.
  • Extend later normalization of arithmetic input to also convert '/' and full-width slash to the canonical division symbol and keep mapping for other operators and parentheses.
  • Broaden the allowed character set for filtering to include both canonical and ASCII forms of arithmetic operators so they are not removed during cleanup.
src/widgets/inputedit.cpp
Adjust point fault tolerance splitting and replacement indices so that operator characters at the split position are preserved while applying fault tolerance to left and right sub-expressions.
  • Change the right-hand substring for fault tolerance to start after the operator character at the split index instead of including it.
  • Update the replacement ranges for left and right substrings to avoid overwriting the operator at the split point when applying symbol fault tolerance.
src/widgets/expressionbar.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:

  • The operator normalization logic (full-width/ASCII variants for +, -, *, /, parentheses, etc.) is duplicated and slightly diverging between normalizedExpr and reformatStr; consider extracting this into a shared helper to keep behavior consistent and easier to maintain.
  • The allowedStatic string now includes both normalized and raw operator forms (+-×÷+-*/); double-check that this set matches the intended normalization pipeline and that operators aren’t unintentionally allowed or disallowed at different stages.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The operator normalization logic (full-width/ASCII variants for +, -, *, /, parentheses, etc.) is duplicated and slightly diverging between `normalizedExpr` and `reformatStr`; consider extracting this into a shared helper to keep behavior consistent and easier to maintain.
- The `allowedStatic` string now includes both normalized and raw operator forms (`+-×÷+-*/`); double-check that this set matches the intended normalization pipeline and that operators aren’t unintentionally allowed or disallowed at different stages.

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.

Skip the current operator when applying right-side symbol fault tolerance.

This prevents expressions like 89*2 from being rewritten as 892 after Qt6 operator matching fixes made the cleanup branch active.

Log: 修复乘号输入后被容错清理误删的问题

Influence: 修复键盘输入乘除等运算符后继续输入数字时运算符丢失的问题。
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL, lzwind

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

@lzwind
lzwind merged commit 1f7a347 into linuxdeepin:master Jul 10, 2026
19 checks passed
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.

3 participants