Search bar: whole-word seach fixed for Unicode, search dialog style improved#2729
Open
Alspb wants to merge 3 commits into
Open
Search bar: whole-word seach fixed for Unicode, search dialog style improved#2729Alspb wants to merge 3 commits into
Alspb wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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 andunicode: trueregex mode. - Restyle the search dialog controls to use
QuillToolbarIconButtonand 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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Unicode-aware whole-word search. Dart's
\b/\ware 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 withunicode: trueon theRegExp.Search bar restyled to match the toolbar better The dialog's
close / settings / prev / next buttons now use
QuillToolbarIconButtonand inherit the toolbar'sQuillIconTheme(size, colors, hover/selected styling). Heights tightened, buttons get a circular shape and compact visual density, etc.
Type of Change