summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 8b29fd3..069cc60 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -1942,6 +1942,32 @@ test("TextView creation reads one operation-local snapshot", function()
end, "immutable")
end)
+test("TextView indexes only lines required by an operation", function()
+ local indexed = {}
+ local view = text_topology.new({ "aaa", "bbb", "ccc" }, "utf-8", {
+ splitter = function(text)
+ indexed[#indexed + 1] = text
+ return text_topology.split_editor_characters(text)
+ end,
+ encoder = function(character)
+ return character
+ end,
+ })
+
+ same(0, #indexed)
+ local positions = collect_iteration(view:iter_strict_forward(
+ domain.Position.new(2, 1),
+ domain.SearchScope.CURRENT_LINE
+ ))
+ list_same({ "(2,2)", "(2,3)" }, position_strings(positions))
+ list_same({ "bbb" }, indexed)
+ same("bb\nccc", view:text_suffix(domain.Position.new(2, 2)))
+ list_same({ "bbb" }, indexed)
+
+ same(3, view:line_character_count(1))
+ list_same({ "bbb", "aaa" }, indexed)
+end)
+
test("All-empty buffers expose empty full-buffer iteration", function()
local view = text_topology.new({ "", "", "" }, "utf-8")
local bounds = view:buffer_match_start_bounds()