aboutsummaryrefslogtreecommitdiff
path: root/files.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 14:57:37 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 14:57:56 -0700
commit4fa9757fa27d79a0cda399dcf3b711f4d0d60457 (patch)
treea67d210b87912ac023822b3e69c97c406659e139 /files.lua
parent0fe94570b5c33e01472f61fcd564809f93e1b08a (diff)
Better handling of parsing non-filechunks text.
Diffstat (limited to 'files.lua')
-rw-r--r--files.lua10
1 files changed, 9 insertions, 1 deletions
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]*}