Skip to content

Search bar: whole-word seach fixed for Unicode, search dialog style improved#2729

Open
Alspb wants to merge 3 commits into
singerdmx:masterfrom
Alspb:search_bar_improvements
Open

Search bar: whole-word seach fixed for Unicode, search dialog style improved#2729
Alspb wants to merge 3 commits into
singerdmx:masterfrom
Alspb:search_bar_improvements

Conversation

@Alspb
Copy link
Copy Markdown
Collaborator

@Alspb Alspb commented May 11, 2026

Description

  1. Unicode-aware whole-word search. Dart's \b/\w are ASCII-only,
    so toggling "whole word" produced no matches for non-ASCII text
    (Cyrillic, CJK, accented Latin, etc.). The pattern now uses Unicode
    property escapes [\p{L}\p{N}\p{M}_] in lookarounds with
    unicode: true on the RegExp.

  2. Search bar restyled to match the toolbar better The dialog's
    close / settings / prev / next buttons now use
    QuillToolbarIconButton and inherit the toolbar's QuillIconTheme
    (size, colors, hover/selected styling). Heights tightened, buttons get a circular shape and compact visual density, etc.

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

Copilot AI review requested due to automatic review settings May 11, 2026 09:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the editor’s search feature by fixing whole-word matching for non-ASCII text and aligning the search dialog’s UI styling with the toolbar button system.

Changes:

  • Update Document.search() whole-word matching to be Unicode-aware using Unicode property escapes and unicode: true regex mode.
  • Restyle the search dialog controls to use QuillToolbarIconButton and toolbar icon theming, with tighter sizing/density.
  • Pass icon sizing and icon theme from the search toolbar button into the dialog for consistent appearance.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lib/src/toolbar/buttons/search/search_dialog.dart Restyles dialog buttons to use QuillToolbarIconButton, adds size/theme inputs, and adjusts layout density.
lib/src/toolbar/buttons/search/search_button.dart Passes effective icon size and QuillIconTheme into the search dialog.
lib/src/document/document.dart Fixes whole-word search to work correctly with Unicode text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +134 to +157
final iconTheme = widget.iconTheme?.copyWith(
iconButtonUnselectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
iconButtonSelectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
) ??
const QuillIconTheme(
iconButtonUnselectedData: IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
iconButtonSelectedData: IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
);
Comment on lines +130 to +146
const buttonBox = BoxConstraints.tightFor(width: 40, height: 40);
const buttonStyle = ButtonStyle(
shape: WidgetStatePropertyAll<OutlinedBorder?>(CircleBorder()),
);
final iconTheme = widget.iconTheme?.copyWith(
iconButtonUnselectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
iconButtonSelectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
constraints: buttonBox,
style: buttonStyle,
),
) ??
const QuillIconTheme(
Comment on lines +365 to +371
// Dart's `\b`/`\w` are ASCII-only. Use Unicode-aware lookarounds instead.
if (wholeWord) {
pattern = r'\b' + pattern + r'\b';
pattern =
r'(?<![\p{L}\p{N}\p{M}_])' + pattern + r'(?![\p{L}\p{N}\p{M}_])';
}
final searchExpression = RegExp(pattern, caseSensitive: caseSensitive);
final searchExpression =
RegExp(pattern, caseSensitive: caseSensitive, unicode: true);
import '../../../document/document.dart';
import '../../../document/nodes/leaf.dart';
import '../../../l10n/extensions/localizations_ext.dart';
import '../../simple_toolbar.dart';
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