-
Notifications
You must be signed in to change notification settings - Fork 246
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
[SuperEditor] Limit tag expansion to caret position (Resolves #2240, #2241, #2242) #2387
base: main
Are you sure you want to change the base?
Conversation
@alterhuman @KevinBrendel Would you mind trying this PR? |
@angelosilvestre thanks for the PR Working correctly:
Issues:
_document = MutableDocument(nodes: [
ParagraphNode(
id: Editor.createNodeId(),
text: AttributedText("Some Infor/mation"),
),
]);
|
@alterhuman I fixed the first issue you mentioned. For the second issue, I'm not sure I followed. It doesn't seem to be related to any of the existing issues. |
@angelosilvestre tested the first issue, it's working correctly. This is the video of second issue, this text is already present in the document when it is opened: Screen.Recording.2024-10-31.at.6.16.39.PM.movFocusing on a word which already has a |
@alterhuman Is this happening on latest main? It doesn't look like it's related to the changes of this PR. If so, can you file a separate issue for this? |
@angelosilvestre yes this is also happening on main. Will file a separate issue for this. All good for this PR. |
@@ -10,11 +10,15 @@ import 'package:super_editor/src/default_editor/text.dart'; | |||
class TagFinder { | |||
/// Finds a tag that touches the given [expansionPosition] and returns that tag, | |||
/// indexed within the document, along with the [expansionPosition]. | |||
/// | |||
/// If [endPosition] is provided, the search will be limited to the range between |
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.
I don't understand this description of endPosition
. This method was intended to only look for tags that touch expansionPosition
, which is a singular position. There shouldn't be a range involved. So the idea of an endPosition
doesn't make sense to me.
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.
So should we keep this method as it was before and modify the reaction to adjust the reported tag?
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.
My point was that I don't know what you're trying to do here because it doesn't seem to make sense. I can't answer that question until I first understand what exactly you were trying to do.
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.
What I'm trying to do is to prevent the tag to expand beyond the caret position. For example, if we have the string "helloworld" and the user types a "/" at the middle, changing it to "hello/world", the string "world" shouldn't be attributed as a tag. The user can input a tag in the middle of a word, but the tag shouldn't expand beyond the caret position.
[SuperEditor] Limit tag expansion to caret position. Resolves #2240, #2241, #2242
Steps to reproduce:
The editor crashes with the following exception:
While investigating this, I noticed that typing "/" at the middle of the word causes all the text that comes after the "/" to be part of the action tag:
Screen.Recording.2024-10-29.at.20.23.32.mov
This doesn't look like is expected.
This PR changes this behavior. Now, the tag is expanded only until the caret position:
Screen.Recording.2024-10-29.at.20.25.46.mov
Changing this seems to already fix the issue, and also #2241 and #2242