Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

improved splitting: sort entries #59

Merged

Conversation

emmanueltouzery
Copy link
Contributor

fixes #57

this seems to work well according to my testing.

Copy link
Owner

@luckasRanarison luckasRanarison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! You just forgot the nil check, it could throw an error.

end

path_map[key] = tostring(count)
file_path:write(markdown, "w")
count = count + 1
end

table.sort(index.entries, function(a, b)
local index_a = sort_lookup[a.path]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local index_a = sort_lookup[a.path]
local index_a = sort_lookup[a.path] or -1

end

path_map[key] = tostring(count)
file_path:write(markdown, "w")
count = count + 1
end

table.sort(index.entries, function(a, b)
local index_a = sort_lookup[a.path]
local index_b = sort_lookup[b.path]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local index_b = sort_lookup[b.path]
local index_b = sort_lookup[b.path] or -1

local split = vim.split(pattern, " ")
local header = split[1]
local top_header = header and header:sub(1, #header - 1)
local next_pattern_lines = vim.split(next_pattern, "\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next_pattern could be nil

local header = split[1]
local top_header = header and header:sub(1, #header - 1)
local next_pattern_lines = vim.split(next_pattern, "\n")
local next_search_pattern = create_pattern(next_pattern_lines[1]) -- only search the first line

for _, line in ipairs(lines) do
if found then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and?

@emmanueltouzery
Copy link
Contributor Author

I now applied the review comments in a followup commit!

@luckasRanarison luckasRanarison merged commit 58239a5 into luckasRanarison:master Oct 23, 2023
1 check passed
@luckasRanarison
Copy link
Owner

Thanks! It's also backward compatible :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants