diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 17:57:21 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 17:57:21 +0200 |
| commit | 50e55afa99aa9feca294a5178bad9fcb42efb704 (patch) | |
| tree | c222ff5c3074b32f33423391319ae0a3e3d04349 /tests | |
| parent | 6c79cf1a6b521b6644da646ede2ffc1e53ce8295 (diff) | |
Index text snapshots lazily by line
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run.lua | 26 |
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() |
