I’m wondering, when is
view.visibleRanges actually needed? Can visible ranges differ from the whole document only when folding is used? Do visible ranges also reflect something like editor being moved out of viewport or when scrolls are being used? Or maybe in some other circumstances?
In short - when
.visibleRanges are being changed?
Mostly in plugins that style content somehow but want to save work by not running over the entire document. For example syntax highlighting, special character replacement, and similar.
@marijn Thank you for your answer, but that’s not quiet what I’m after.
I’m creating an editor, and I try to write tests for that editor. I’ve created tests for commands, keys, autocomplete, and other stuff.
But whatever I do, when I run tests, and I call
view.visibleRanges, I always get exactly one range, and that range is always
[0, x] where
I was not able to create a scenario in tests that would give me multiple ranges. Hence my question, what situations can give me visibleRanges?
I expect fold gutters might do that, but what else?
- If I add scroll to editor, will the lines scrolled out (not visible) cause
.visibleRanges to have some effect?
- If I don’t add a scroll to editor, but I will scroll the page so that the editor is out of the viewport, will that cause
.visibleRanges to show empty ranges?
- Are there some other scenarios that cause
.visibleRanges to return something else?
I don’t use gutters (fold or other) currently in my editor - does this mean that I don’t need to use
.visibleRanges in my custom plugins? Or should I still use them, because of some wierd edge case.
If the doc is big enough that the viewport doesn’t cover all of it,
visibleRanges will match the viewport. If there are super-long lines that are partially kept out of view, you may get multiple ranges.