Skip to content

[Request] Filter entries by given range? #57

@Ajaymamtora

Description

@Ajaymamtora

Could we add an option to filter the picker entries by a given range?

For example we could bind in visual selection to take the start and end lines, and pass that into telescope-undo, then filter entries if they don't have a diff between the given lines? I used this a lot in IntelliJ and it would be useful to have here. It probably doesnt have to be smart and try and resolve where code has moved about between diffs, could probably just check the diff lies between the given line numbers

Maybe something like this before passing it into telescope:

local function undo_history_for_range(startline, endline)
    local undotree = vim.fn.undotree()
    local changes = {}

    for _, entry in ipairs(undotree.entries) do
        for _, change in ipairs(entry.changes or {}) do
            if change.new_start >= startline and change.old_end <= endline then
                table.insert(changes, change)
            end
        end
    end

    return changes
end

-- Example usage: Get undo history for lines 10 to 20
local changes = undo_history_for_range(10, 20)
print(vim.inspect(changes))

https://www.jetbrains.com/help/idea/local-history.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions