summaryrefslogtreecommitdiff
path: root/lua/clever_f/text_topology.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/text_topology.lua')
-rw-r--r--lua/clever_f/text_topology.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lua/clever_f/text_topology.lua b/lua/clever_f/text_topology.lua
index 2941cf2..56f3b9c 100644
--- a/lua/clever_f/text_topology.lua
+++ b/lua/clever_f/text_topology.lua
@@ -418,6 +418,26 @@ function TextView:line_encoded_text(line_number)
return line_record(self, line_number).encoded
end
+function TextView:text_suffix(position)
+ position = domain.Position.coerce(position)
+ local record = view_record(self)
+ local line = line_record(self, position.line)
+ local character_index = self:character_index_for_byte_column(
+ position.line,
+ position.byte_column
+ )
+ local parts = {}
+
+ for index = character_index, line.character_count do
+ parts[#parts + 1] = line.entries[index].character
+ end
+ for line_number = position.line + 1, record.snapshot.line_count do
+ parts[#parts + 1] = "\n"
+ parts[#parts + 1] = record.lines[line_number].text
+ end
+ return table.concat(parts)
+end
+
function TextView:line_byte_length(line_number)
return line_record(self, line_number).byte_length
end
@@ -970,6 +990,8 @@ TextView.character_index_to_byte_column = TextView.byte_column_for_character_ind
TextView.byte_column_to_character_index = TextView.character_index_for_byte_column
TextView.character_count = TextView.line_character_count
TextView.byte_length = TextView.line_byte_length
+TextView.text_from = TextView.text_suffix
+TextView.suffix_from = TextView.text_suffix
TextView.character_span = TextView.byte_span_for_character_index
TextView.predecessor_endpoint = TextView.predecessor
TextView.successor_endpoint = TextView.successor