From 65dc1f2196b46dbd527d49da113515bea825416d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 26 Jun 2018 15:52:38 -0700 Subject: Cleaning up metaprogramming a bit and fixing/adding test for recursion control flow. --- files.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'files.lua') diff --git a/files.lua b/files.lua index ded403a..8163ab4 100644 --- a/files.lua +++ b/files.lua @@ -161,4 +161,11 @@ files.get_line_number = function(str, pos) end return hi end +files.get_line = function(str, line_no) + local line_starts = files.get_line_starts(str) + return str:sub(line_starts[line_no] or 1, line_starts[line_no + 1] or -1) +end +files.get_lines = function(str) + return get_lines:match(str) +end return files -- cgit v1.2.3