(renderer) rename vars, add comments
All checks were successful
NeoVim tests / plenary-tests (push) Successful in 11s

This commit is contained in:
Jonathan Apodaca 2025-04-12 09:10:03 -06:00
parent 362d9e905d
commit dacb186324

View File

@ -434,7 +434,7 @@ function TreeBuilder:tree() return self.nodes end
--- @param x `T`[] --- @param x `T`[]
--- @param y T[] --- @param y T[]
--- @param cost? { of_delete?: fun(x: T): number; of_add?: fun(x: T): number; of_change?: fun(x: T, y: T): number; } --- @param cost? { of_delete?: fun(x: T): number; of_add?: fun(x: T): number; of_change?: fun(x: T, y: T): number; }
--- @return LevenshteinChange<T>[] --- @return LevenshteinChange<T>[] The changes, from last (greatest index) to first (smallest index).
function H.levenshtein(x, y, cost) function H.levenshtein(x, y, cost)
-- At the moment, this whole `cost` plumbing is not used. Deletes have the -- At the moment, this whole `cost` plumbing is not used. Deletes have the
-- same cost as Adds or Changes. I can imagine a future, however, where -- same cost as Adds or Changes. I can imagine a future, however, where
@ -474,10 +474,10 @@ function H.levenshtein(x, y, cost)
if x[i] == y[j] then if x[i] == y[j] then
dp[i][j] = dp[i - 1][j - 1] -- no cost if items are the same dp[i][j] = dp[i - 1][j - 1] -- no cost if items are the same
else else
local costDelete = dp[i - 1][j] + cost_of_delete_f(x[i]) local cost_delete = dp[i - 1][j] + cost_of_delete_f(x[i])
local costAdd = dp[i][j - 1] + cost_of_add_f(y[j]) local cost_add = dp[i][j - 1] + cost_of_add_f(y[j])
local costChange = dp[i - 1][j - 1] + cost_of_change_f(x[i], y[j]) local cost_change = dp[i - 1][j - 1] + cost_of_change_f(x[i], y[j])
dp[i][j] = math.min(costDelete, costAdd, costChange) dp[i][j] = math.min(cost_delete, cost_add, cost_change)
end end
end end
end end