Skip to content
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

[BUG] - Exception when deleting composing action tag, then starting new one #2240

Open
KevinBrendel opened this issue Aug 14, 2024 · 1 comment
Assignees
Labels
area_supereditor Pertains to SuperEditor bounty_junior f:superlist Funded by Superlist time:2 type_bug Something isn't working

Comments

@KevinBrendel
Copy link
Contributor

Package Version
super_editor, GitHub, main branch

User Info
coneno, QuikFlow

To Reproduce
Steps to reproduce the behavior:

  1. Go to the "Action Tags" section of the example app
  2. Type some text
  3. Place the cursor in the middle of the text
  4. Type "/"
  5. Press backspace
  6. Type "/" again
  7. See exception

Actual behavior

════════ Exception caught by services library ══════════════════════════════════
The following _Exception was thrown during method call TextInputClient.updateEditingStateWithDeltas:
Exception: removeAttribution() did not satisfy start < 0 and start > end, start: 6, end: 5

When the exception was thrown, this was the stack:
#0      AttributedSpans.removeAttribution (package:attributed_text/src/attributed_spans.dart:514:7)
attributed_spans.dart:514
#1      RemoveTextAttributionsCommand.execute (package:super_editor/src/default_editor/text.dart:1444:15)
text.dart:1444
#2      _DocumentEditorCommandExecutor.executeCommand (package:super_editor/src/core/editor.dart:701:15)
editor.dart:701
#3      Editor._executeCommand (package:super_editor/src/core/editor.dart:304:22)
editor.dart:304
#4      Editor.execute (package:super_editor/src/core/editor.dart:266:30)
editor.dart:266
#5      ActionTagComposingReaction._healCancelledTags (package:super_editor/src/default_editor/text_tokenizing/action_tags.dart:364:23)
action_tags.dart:364
#6      ActionTagComposingReaction.react (package:super_editor/src/default_editor/text_tokenizing/action_tags.dart:286:5)
action_tags.dart:286
#7      Editor._reactToChanges (package:super_editor/src/core/editor.dart:357:16)
editor.dart:357
#8      Editor.endTransaction (package:super_editor/src/core/editor.dart:222:5)
editor.dart:222
#9      TextDeltasDocumentEditor.applyDeltas (package:super_editor/src/default_editor/document_ime/document_delta_editing.dart:118:12)
document_delta_editing.dart:118
#10     DocumentImeInputClient.updateEditingValueWithDeltas (package:super_editor/src/default_editor/document_ime/document_ime_communication.dart:232:30)
document_ime_communication.dart:232
#11     DeltaTextInputClientDecorator.updateEditingValueWithDeltas (package:super_editor/src/default_editor/document_ime/ime_decoration.dart:129:14)
ime_decoration.dart:129
#12     TextInput._handleTextInputInvocation (package:flutter/src/services/text_input.dart:1906:63)
text_input.dart:1906
#13     TextInput._loudlyHandleTextInputInvocation (package:flutter/src/services/text_input.dart:1794:20)
text_input.dart:1794
#14     MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:571:55)
platform_channel.dart:571
#15     MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:564:34)
platform_channel.dart:564
#16     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:581:35)
binding.dart:581
#17     _invoke2 (dart:ui/hooks.dart:344:13)
hooks.dart:344
#18     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
channel_buffers.dart:45
#19     _Channel.push (dart:ui/channel_buffers.dart:135:31)
channel_buffers.dart:135
#20     ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17)
channel_buffers.dart:343
#21     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:750:22)
platform_dispatcher.dart:750
#22     _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)
hooks.dart:257

call: MethodCall(TextInputClient.updateEditingStateWithDeltas, [7, {deltas: [{selectionBase: 8, oldText: . asdfasdf, selectionAffinity: TextAffinity.downstream, deltaEnd: 7, deltaText: /, deltaStart: 7, composingExtent: -1, selectionIsDirectional: false, selectionExtent: 8, composingBase: -1}]}])
════════════════════════════════════════════════════════════════════════════════

Expected behavior
A new action tag is being composed.

Platform
macOS

Flutter version
Flutter 3.22.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b0850beeb2 (4 weeks ago) • 2024-07-16 21:43:41 -0700
Engine • revision 235db911ba
Tools • Dart 3.4.4 • DevTools 2.34.3

Screenshots
Screenshot 2024-08-14 at 13 05 15

@KevinBrendel KevinBrendel added the type_bug Something isn't working label Aug 14, 2024
@KevinBrendel
Copy link
Contributor Author

KevinBrendel commented Aug 15, 2024

@matthew-carroll
The cause for this and for #2241 as well as #2242 appears to be that _cancelComposingTag uses _composingTag as a reference, which can be outdated if _cancelComposingTag is called because tagAroundPosition is null.

Fixed it by directly using the actionTagComposingAttribution range(s) as a reference for now:
coneno@e95e848

Could of course be more optimized, in case there can actually only be one range, even if inserting a space, etc.

Needs further testing, but so far this implementation appears to fix all three issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_supereditor Pertains to SuperEditor bounty_junior f:superlist Funded by Superlist time:2 type_bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants