sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

Add a `$select_ref` selector for custom commands

Open FichteFoll opened this issue 1 year ago • 3 comments

Problem description

The currently available selectors for custom commands are a bit too special-purpose and allow for selecting either a tag, a branch or a commit, but only that specifically. What I'm missing is a $select_ref selector that I can use for a command like git rebase, where I'd like to rebase onto a tag, a branch, or a commit, depending on the situation. In fact, many git commands take a "ref". Currently, I'd need to create a separate command for each variation. When creating a custom command for e.g. git rebase --onto, I want to select two refs, meaning I'd need to create 3*3 different commands and I'd need to know ahead of time what exactly it is I want to select in each position (which I generally do but I don't want to think about that when invoking this kind of operation).

Preferred solution

A $select_ref selector that allows me to select any git ref, i.e. a branch, a tag, or a commit. Branch and tag names should be prioritized over a commit's summary line (usually displayed on the right side).

Example .sublime-command entry:

    {
        "caption": "Rebase onto…",
        "command": "git",
        "args": {"argv": ["rebase", "$select_ref", "--onto", "$select_ref"]},
    },

Alternatives

Create a separate command for each option combination (already possible but not desired).

FichteFoll avatar May 13 '24 09:05 FichteFoll

Has been added in 2099.

FichteFoll avatar Aug 13 '24 11:08 FichteFoll

Actually, commits are not shown in the select_ref menu. Only tags and branches are. Sometimes, searching for the git commit summary line that is almost always visible on the left-hand side is faster than figuring out which branch or tag points towards it, if any.

For now, I'll just use two command palette entries, one with select_ref and one with select_commit, as you'd generally know ahead of time what you want. I don't use it frequently enough to warrant a key binding. I'll reopen the ticket anyway for discussion.

FichteFoll avatar Aug 13 '24 11:08 FichteFoll

I was a bit disappointed too, when I saw it does not include commit hashes. Actually not sure whether the fuzzy search would work good with it mixed in. Maybe some magic trigger like a preceeding # would be an idea. Or whether an additional command for all would be better.

themilkman avatar Aug 13 '24 15:08 themilkman