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

Fix range bound crash when startIndex greater than or equal to endIndex #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wonderhero
Copy link

@wonderhero wonderhero commented Nov 19, 2019

Range bound will crash when startIndex greater than or equal to endIndex in some case.

@codecov
Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #122 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #122   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          21     21           
  Lines         975    976    +1     
=====================================
+ Hits          975    976    +1
Impacted Files Coverage Δ
Classes/MentionListener.swift 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0b6ce2...a0d9b12. Read the comment docs.

@szweier
Copy link
Owner

szweier commented Nov 19, 2019

Can you please add a test that presents the issue and proves the fix.

@wonderhero
Copy link
Author

Hi szweier,

I was trying to reproduce the issue in this sample project, however I am still unable to reproduce it by using the test project. The crash is happened to my project with following steps:

  1. Mention a string which contains emoji. [Not happen if the display name without any emoji]
  2. Mention any second string.
  3. Move the caret/cursor (in the UITextView) to the last position of first mentioned string.
  4. When calling handleMentionsList with searchSpaces enabled, the code crash in the line 271 (MentionListener class) which XCode complaning that upper bound value lower than lower bound value.

After I have added the checking to the code to prevent the upper bound value lower than the lower bound value then it solved the issue.

I am still trying to make this happen to the test project in this library, but I have no luck to make it happen.

@szweier
Copy link
Owner

szweier commented Feb 15, 2020

@wonderhero I'm having a hard time reproducing this. Can you tell me the exact text you have in the field and where you move the cursor that triggers the issue. I'm assuming it's something along the lines of @Test Name text @Other Name neither of which is a chosen mention but rather when you move the cursor to either location it opens the mention selector. Having the exact copy might help me reproduce the issue.

@wonderhero
Copy link
Author

@szweier thank you for your great helper. I am trying to get you the exact text that I have input to the field and causing the crash.

Text that I have been using: @first_mention_name_with_emoji_😄@second_mention_name_with_emoji_😸
(Mention must include with emoji)

However, I could not reproduce by using the test project in this library. I doubt the crash is due to the cursor is moving to a location where it is opening the mention selector and also due to some other extra workflow (on text view) that defined in my working project.

It is when I point my cursor to behind of first smiley in text above and crash happen when opening the mention selector. Sorry for unable to provide a promising test case for you. I will keep trying and update you again.

@szweier
Copy link
Owner

szweier commented Feb 15, 2020

Thanks. Is your project where the issue is happening public?

@wonderhero
Copy link
Author

@szweier currently working in a private repo for my company.

@szweier
Copy link
Owner

szweier commented Feb 16, 2020

@wonderhero can you try using the changes in https://github.com/szweier/SZMentionsSwift/pull/130/files in your private repo. I just came across this issue when using your example above and while I can't reproduce the problem you describe I did find an issue that needs to be fixed and thought it might help avoid hitting the issue you have.

@wonderhero
Copy link
Author

@szweier I have tried in my private repo, the issue still persists. I am currently trying to use the example in this library to reproduce the issue. Trying to compare the difference between my projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants