nathantannar4 / InputBarAccessoryView

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments
MIT License
1.17k stars 229 forks source link

AutoCompleteManager Index out of bounds when using custom prefix #242

Open bevbomb opened 1 year ago

bevbomb commented 1 year ago

Describe the bug When using an autocomplete prefix starting with a forward slash like "/name", I get an index out-of-bounds error at line 180 in AutoCompletemanager let wordWithoutPrefix = (result.word as NSString).substring(from: result.prefix.utf16.count)

When checking the error, the word registered in the autocomplete is picking up as e, its almost as if the index is out by one due to the forward slash being used and the result returned is showing e as a word following the prefix.

To Reproduce Steps/code to reproduce the behavior: Register a new autocomplete prefix like so autocompleteManager.register(prefix: "/name") in the example app and try and use the prefix in the input bar, it will throw an error.

Expected behavior I am under the assumption I should be able to use /name as a prefix similar to how Slack uses forward slash commands and then select from the results returned.

Environment

Additional context Add any other context about the problem here.