[GH-ISSUE #1997] [Bug] Exception thrown after inserting '/' slash in middle of text #789

Closed
opened 2026-03-23 20:41:05 +00:00 by mirror · 2 comments
Owner

Originally created by @zoli on GitHub (Mar 15, 2023).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/1997

Originally assigned to: @LucasXu0 on GitHub.

Bug Description

inserting '/' slash in middle of text causes exception.

How to Reproduce

Go to any line including text and insert '/' in the middle of the text.

Expected Behavior

To insert '/' and show slash command menu or at least not throw exception.

Operating System

Arch Linux

AppFlowy Version(s)

Exists on 4c0168d7fa commit

Screenshots

No response

Additional Context

Probably the root cause are changes in this commit.

Originally created by @zoli on GitHub (Mar 15, 2023). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/1997 Originally assigned to: @LucasXu0 on GitHub. ### Bug Description inserting '/' slash in middle of text causes exception. ### How to Reproduce Go to any line including text and insert '/' in the middle of the text. ### Expected Behavior To insert '/' and show slash command menu or at least not throw exception. ### Operating System Arch Linux ### AppFlowy Version(s) Exists on 4c0168d7faa556910b6a0cef06e0385a5d2978db commit ### Screenshots _No response_ ### Additional Context Probably the root cause are changes in [this](https://github.com/AppFlowy-IO/AppFlowy/commit/085ef8f668697081d92ae500810a9124e9b71966) commit.
mirror 2026-03-23 20:41:05 +00:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@LucasXu0 commented on GitHub (Mar 15, 2023):

Hey, @zoli. Can you share the exception message?

<!-- gh-comment-id:1469507655 --> @LucasXu0 commented on GitHub (Mar 15, 2023): Hey, @zoli. Can you share the exception message?
Author
Owner

@zoli commented on GitHub (Mar 15, 2023):

Hey, @zoli. Can you share the exception message?

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following StateError was thrown while processing the key message handler:
Bad state: No element

When the exception was thrown, this was the stack:
#0      Iterable.first (dart:core/iterable.dart:624:7)
#1      TextTransaction.replaceText (package:appflowy_editor/src/core/transform/transaction.dart:271:57)
#2      slashShortcutHandler.<anonymous closure>
(package:appflowy_editor/src/service/internal_key_event_handlers/slash_handler.dart:24:7)
#3      _AppFlowyKeyboardState.onKey (package:appflowy_editor/src/service/keyboard_service.dart:133:45)
#4      _AppFlowyKeyboardState._onKey (package:appflowy_editor/src/service/keyboard_service.dart:157:12)
#5      FocusManager._handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1683:32)
#6      KeyEventManager._dispatchKeyMessage (package:flutter/src/services/hardware_keyboard.dart:824:34)
#7      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:889:17)
#8      BasicMessageChannel.setMessageHandler.<anonymous closure>
(package:flutter/src/services/platform_channel.dart:197:49)
#9      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#10     _invoke2 (dart:ui/hooks.dart:186:13)
#11     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#12     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#13     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#14     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#15     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)

KeyMessage: KeyMessage([KeyDownEvent#e9c4e(physicalKey: PhysicalKeyboardKey#70038(usbHidUsage:
  "0x00070038", debugName: "Slash"), logicalKey: LogicalKeyboardKey#0002f(keyId: "0x0000002f",
  keyLabel: "/", debugName: "Slash"), character: "/", timeStamp: 46:54:13.925000)])
════════════════════════════════════════════════════════════════════════════════════════════════════
<!-- gh-comment-id:1469523843 --> @zoli commented on GitHub (Mar 15, 2023): > Hey, @zoli. Can you share the exception message? ``` ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════ The following StateError was thrown while processing the key message handler: Bad state: No element When the exception was thrown, this was the stack: #0 Iterable.first (dart:core/iterable.dart:624:7) #1 TextTransaction.replaceText (package:appflowy_editor/src/core/transform/transaction.dart:271:57) #2 slashShortcutHandler.<anonymous closure> (package:appflowy_editor/src/service/internal_key_event_handlers/slash_handler.dart:24:7) #3 _AppFlowyKeyboardState.onKey (package:appflowy_editor/src/service/keyboard_service.dart:133:45) #4 _AppFlowyKeyboardState._onKey (package:appflowy_editor/src/service/keyboard_service.dart:157:12) #5 FocusManager._handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1683:32) #6 KeyEventManager._dispatchKeyMessage (package:flutter/src/services/hardware_keyboard.dart:824:34) #7 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:889:17) #8 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49) #9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35) #10 _invoke2 (dart:ui/hooks.dart:186:13) #11 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5) #12 _Channel.push (dart:ui/channel_buffers.dart:132:31) #13 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17) #14 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22) #15 _dispatchPlatformMessage (dart:ui/hooks.dart:89:31) KeyMessage: KeyMessage([KeyDownEvent#e9c4e(physicalKey: PhysicalKeyboardKey#70038(usbHidUsage: "0x00070038", debugName: "Slash"), logicalKey: LogicalKeyboardKey#0002f(keyId: "0x0000002f", keyLabel: "/", debugName: "Slash"), character: "/", timeStamp: 46:54:13.925000)]) ════════════════════════════════════════════════════════════════════════════════════════════════════ ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#789
No description provided.