From 4fa9757fa27d79a0cda399dcf3b711f4d0d60457 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Jul 2018 14:57:37 -0700 Subject: Better handling of parsing non-filechunks text. --- files.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'files.lua') diff --git a/files.lua b/files.lua index c6da8c8..2999c7d 100644 --- a/files.lua +++ b/files.lua @@ -229,7 +229,15 @@ Files.get_line_number = function(str, pos) 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) - 2) + local start = line_starts[line_no] + if not (start) then + return + end + local stop = line_starts[line_no + 1] + if not (stop) then + return + end + return str:sub(start, stop - 2) end local get_lines = re.compile([[ lines <- {| line (%nl line)* |} line <- {[^%nl]*} -- cgit v1.2.3