-
Notifications
You must be signed in to change notification settings - Fork 23
Adjust start offset calculation for query selection #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ViscousPot
wants to merge
5
commits into
xsahil03x:master
Choose a base branch
from
ViscousPot:ViscousPot-patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a1358fe
Adjust start offset calculation for query selection
ViscousPot b58982f
Fix null safety issue with currentTrigger
ViscousPot 60d5b16
Update multi_trigger_autocomplete.dart
ViscousPot 6662bb6
Add tests for multi-character autocomplete triggers
ViscousPot e30fd06
Enhance multi-character trigger autocomplete test
ViscousPot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,6 +297,57 @@ void main() { | |
| expect(find.byKey(fieldKey), findsOneWidget); | ||
| expect(find.byType(TextFormField), findsNothing); | ||
| }); | ||
|
|
||
| testWidgets('handles multi-character triggers with keepTrigger=false', (tester) async { | ||
| final multiCharTrigger = AutocompleteTrigger( | ||
| trigger: '##' | ||
| optionsViewBuilder: (context, query, controller) { }, | ||
| ); | ||
|
|
||
| await tester.pumpWidget( | ||
| Boilerplate( | ||
| child: MultiTriggerAutocomplete( | ||
| autocompleteTriggers: [multiCharTrigger], | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| await tester.enterText(find.byType(TextFormField), '##'); | ||
|
|
||
| await tester.tap(find.byType(InkWell).first); | ||
| await tester.pump(); | ||
|
|
||
| final TextFormField field = | ||
| find.byType(TextFormField).evaluate().first.widget as TextFormField; | ||
|
|
||
| expect(field.controller!.text, isNot(contains('##'))); | ||
| }); | ||
|
|
||
| testWidgets('cursor position correct after autocomplete with multi-character trigger', (tester) async { | ||
| final multiCharTrigger = AutocompleteTrigger( | ||
| trigger: '@@', | ||
| optionsViewBuilder: (context, query, controller) { }, | ||
| ); | ||
|
|
||
| await tester.pumpWidget( | ||
| Boilerplate( | ||
| child: MultiTriggerAutocomplete( | ||
| autocompleteTriggers: [multiCharTrigger], | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| await tester.enterText(find.byType(TextFormField), '@@sa'); | ||
|
|
||
| await tester.tap(find.byType(InkWell).first); | ||
| await tester.pump(); | ||
|
|
||
| final TextFormField field = | ||
| find.byType(TextFormField).evaluate().first.widget as TextFormField; | ||
|
|
||
| expect(field.controller!.selection.baseOffset, | ||
| equals(field.controller!.text.length)); | ||
| }); | ||
|
||
| }); | ||
| } | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Test has syntax errors and will fail at runtime.
This test has multiple issues that will cause it to fail:
trigger: '##'{ }doesn't return a Widget as required. It must return a widget like ListView with tappable items.find.byType(InkWell).firstbut the empty optionsViewBuilder doesn't create any InkWell widgets, causing the finder to fail.enterText, you should addawait tester.pumpAndSettle(kDebounceDuration);to allow the options to appear (see line 159 for reference).find.byType(ListView)finds a widget before attempting to tap.Apply this diff to fix the test:
📝 Committable suggestion