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

BackgroundTokenizer: State comparison should not be via string compare #5458

Open
dhakehurst opened this issue Jan 8, 2024 · 1 comment
Open

Comments

@dhakehurst
Copy link

dhakehurst commented Jan 8, 2024

Describe the bug

I am implementing my own Tokenizer, that is not line based.
To interface with ace, of course, I need to create line 'states'.
the background Tokenizer uses string comparison to compare line-states.

if (this.states[row] + "" !== data.state + "")

this of course does not work properly unless line states are strings

Expected Behavior

I expected to be able to provide line-states that are not strings.

Current Behavior

line-states not correctly compared, and thus tokens not correctly updated.

Reproduction Steps

use an object to represent line-states rather than a string

Possible Solution

work-around is to ensure that state+"" does return something that 'encodes' the state.
(ie a toString for the state object

correct fix would be a true object comparison in BackgroundTokenizer

Additional Information/Context

No response

Ace Version / Browser / OS / Keyboard layout

1.32.3

@dhakehurst dhakehurst changed the title BackgroundTokenizer: State comparisone should be be via string compare BackgroundTokenizer: State comparison should not be via string compare Jan 8, 2024
@whazor
Copy link
Contributor

whazor commented Jan 10, 2024

toString does not work on null|undefined, so it might need some null/undefined checks to be sure. Maybe there needs to be a check for toString itself. There should be no performance impact, though it should be fine as it runs in the background.

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

No branches or pull requests

3 participants