Skip to content

Fix rust binding to use the chars count instead of byte length#346

Open
arai-a wants to merge 1 commit intosourcegraph:mainfrom
arai-a:rust-sym-chars-count
Open

Fix rust binding to use the chars count instead of byte length#346
arai-a wants to merge 1 commit intosourcegraph:mainfrom
arai-a:rust-sym-chars-count

Conversation

@arai-a
Copy link

@arai-a arai-a commented Nov 14, 2025

The rust binding uses self.sym.chars().nth(self.index) to access chars, but the sym.index uses the [0, self.sym.len()) range.

chars().nth() uses the char index, while sym.len() is the byte length.
This results in InvalidIndex error in SymbolParser::current if the symbol contains non-ASCII range.

This patch introduces a new field sym_len to SymbolParser, which caches the result of chars count (given it's O(N) operation),
and use it in place of sym.len().

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.

1 participant