-- Basic shell history based hinter.
-- It's a bit buggy, but it works (TODO: fix)

local hilbish = require "hilbish"

local M = {}

M.hinter = function(line)
    local his = hilbish.history.all()
    local his_vals = table.filter(his, function(v)
        return v:find(line, 1, true) == 1
    end)
    if #his_vals ~= 0 then
        local base_val = his_vals[#his_vals]
        return string.sub(base_val, string.len(line) + 1, -1)
    end
    return ''
end

return M
