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

Autocomplete popup highlighting fails when string is over 32 chars long #2632

Closed
pthurlow opened this issue Aug 14, 2015 · 1 comment
Closed

Comments

@pthurlow
Copy link

The highlighting implementation for ace autocomplete popup menu relies on a bit mask to determine the location of characters in the string to highlight. Since this bit mask is stored as an integer it can only store characters up to the maximum bits of an integer - 1, 31.

When shifting more than 31 characters the bitwise shift clips the first 31 bits off and converts the remaining bits as shown here:

// shift 1 bit 3 places left to get 8
1 << 3  = 8

// shift 1 bit 31 places left to get almost the max signed integer
1 << 31 = -2147483648

// shift 1 bit 32 places to roll over back to 1
1 << 32 = 1

// shift 1 bit 35 places to get back to 8
1 << 35 = 8

This manifests itself in the autocomplete popover by causing text to get highlighted incorrectly. In this contrived example you can see the character at index 2 is incorrectly highlighted because the masked position of the A to be highlighted is 2 passed the 32nd character in the string.

pthurlow added a commit to pthurlow/ace that referenced this issue Aug 14, 2015
…an bit mask to avoid integer overflow issues. fixes ajaxorg#2632
@Cwallice
Copy link

Cwallice commented Mar 3, 2016

+1
Long names are necessary sometimes.

dmarcotte pushed a commit to looker/ace that referenced this issue Jun 10, 2016
dmarcotte pushed a commit to looker/ace that referenced this issue Jun 10, 2016
dmarcotte pushed a commit to looker/ace that referenced this issue May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants