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

Should selection start/end be limited to the size of the text? #88

Open
dandclark opened this issue Jan 23, 2024 · 3 comments
Open

Should selection start/end be limited to the size of the text? #88

dandclark opened this issue Jan 23, 2024 · 3 comments

Comments

@dandclark
Copy link
Contributor

While looking at #87 I noticed that updateSelection() as currently specified doesn't prevent the author from specifying a selection that's outside the bounds of the text.

This is not what I would have expected; it seems like a potential source of errors to allow selection to be set outside of the text. It's not exactly clear how the browser should handle adjusting selection in these scenarios.

We should consider enforcing that updateSelection() not allow the author to set a selection begin or end larger than the size of EditContext.text.

If we add this restriction, we'd also want to have updateText() adjust the selection offsets if the update would put them outside of the new shortened text.

The current Chromium implementation clamps the selection set in updateSelection() to the length of the text, but does not throw an error.

@dandclark
Copy link
Contributor Author

Similarly, what should happen if in updateText(start, end, text), the specified start/end are outside the bounds of the current text?

Chromium silently clamps start/end to the length of the current text. I wonder if this should throw instead.

@dandclark
Copy link
Contributor Author

EditContext's constructor also allows the selection and text to be specified, so that should be considered here as well.

@dandclark
Copy link
Contributor Author

(Dropping this from the Agenda for the next meeting since I haven't had a chance to make progress on it)

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

No branches or pull requests

2 participants