Sublime Forum

Custom command selectors are replaced by empty string with no prompt

#1

I’m trying to use selectors in a custom command to push a renamed remote ref from my local branch. Something like this:

"caption": "Push Renamed",
"command": "git",
"args": {
    "argv": ["push", "origin", "$head:$text"],
    "prompt": true,
}

However, this doesn’t work and tries to run git push origin <head>:. I want it to prompt the user for text to name the remote branch and then run the command with that text, like git push origin <head>:<user-text>.

It seems like selectors are only observed if they’re the only value for an argument. Since Git’s push subcommand doesn’t support accepting a destination except as part of the ref argument, it seems like there might be no way to do this unless Sublime Merge interpolated selectors into strings.

0 Likes

#2

This is a known limitation of the current stable build, but dev build 2080 (released Dec 5th) includes the changelog item:

Custom commands now support selectors anywhere in an argument

So, I would imagine that this should be possible in that version or in the next stable version whenever that lands.

0 Likes

#3

Thanks! That gets me a little bit closer, but it looks like this only works if there is only a single selector in the argument? Adding a variable causes it to no longer work. So, for instance, the command above still doesn’t work, but if I remove If I remove $head from the last argument, a palette to type in the $text value appears.

0 Likes

#4

If that’s the case and you’re on that build, it might be worth an issue. There are a few git commands that require arguments that need more than one of these, so I would guess that that would be more in the spirit of what this was intended to fix.

0 Likes

#5

Sounds good – I’ve filed https://github.com/sublimehq/sublime_merge/issues/1679 on the issue tracker.

0 Likes