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

Also include "input index" in SourceSpan #348

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

robinst
Copy link
Collaborator

@robinst robinst commented Oct 16, 2024

The existing line/column indexes in SourceSpan are useful for some cases, e.g. editors that are line based. But for other cases, it's useful to be able to get the index within the original input string.

An example: If the input string is "foo\n\nbar", the "bar" paragraph has the following SourceSpan:
line 2 (third line), column 0, length 3.
With this change, now it also includes the input index: 5 ("b" is the character at index 5 in the string).
That means it's possible to use e.g. substring instead of having to split the input text into lines first.

The existing line/column indexes in `SourceSpan` are useful for some cases,
e.g. editors that are line based. But for other cases, it's useful to be able
to get the index within the original input string.

An example: If the input string is "foo\n\nbar", the "bar" paragraph has
the following `SourceSpan`: line 2 (third line), column 0, length 3.
With this change, now it also includes the input index: 5 ("b" is the character
at index 5 in the string). That means it's possible to use e.g. `substring`
instead of having to split the input text into lines first.
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