Skip to content

Commit

Permalink
feat: Avoid errors if object count patterns are passed in as strings
Browse files Browse the repository at this point in the history
This commit prevents an error from being thrown if the user accidentally
passes in a string (instead of a table containing one or more strings)
for object type patterns.
  • Loading branch information
jakewvincent committed Jun 19, 2024
1 parent 1b0e415 commit ac22e37
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/mkdnflow/foldtext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ local count_objects = function(lines)
-- Block method
for k, v in pairs(tally_methods.blocks) do
local match, _line = false, v.prep ~= nil and v.prep(line) or line
-- If a string was passed in for v.pattern, place it in a table to prevent errors
v.pattern = type(v.pattern) == 'string' and {v.pattern} or v.pattern
for _, pattern in ipairs(v.pattern) do
if _line:match(pattern) then
match = true
Expand Down

0 comments on commit ac22e37

Please sign in to comment.