sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
271 stars 14 forks source link

selector arguments behave inconsistently/unexpectedly #943

Open OdatNurd opened 3 years ago

OdatNurd commented 3 years ago

Version info

Description

The new selector variables behave in a bit of an inconsistent and/or unexpected manner, particularly as compared to how someone familiar with similar variable uses in Sublime Text might attempt to use them.

Steps to reproduce

Create and save the following simplistic Python script, which displays its arguments when executed:

#!/bin/env python3
import sys

print(str(sys.argv))

Add an alias to git's config that will execute this script, passing on the first argument:

[alias]
    script = "!f() { /home/tmartin/test.py $1; }; f"

Create a new command palette entry that invokes the git alias using $text as the first argument:

    {
        "caption": "Git command",
        "command": "git",
        "args": {"argv": ["status", "$text"]}
    }
  1. Executing the command from the command palette and entering the text something has the desired effect; when checking the command output, we can see that the command executed as expected:

image

  1. Executing the command again, don't enter any value for the variable and just run it. The command preview shows that git script $text will be executed, and verifiably this is exactly what happens; however one might expect that if they provide no input, that's what $text will expand to.

    The display of the command as git script $'$text' is also a bit confusing in this case (when you don't expect it)

image

  1. If you're used to similar constructs in Sublime Text, you might try to use ${text} in place of $text as the name of the variable; however in doing so the command does not parse and doesn't appear in the command palette at all. No message appears in the console as a warning that something is wrong in this case.

  2. Despite the above, replacing the variable with ${text:default}, presuming that a default value for the variable will be used, does indeed work. You're not prompted for the value and the default is used directly when you invoke the command:

image

Expected behavior

Variables like $text should expand out to the value that you gave, which includes no value at all.

Also, arguably since many users that use Merge may also be using Text, having a similar syntax for a similar item seems like it would make the most sense so that skills

dpjohnst commented 3 years ago

Hi @OdatNurd,

Thanks for the feedback - the first issue mentioned in the description has been resolved as of Sublime Merge Build 2035. Currently we don't support the snippet-style syntax for selectors, though it's something we'd like to eventually add.

I'll leave this issue open in the meantime to track the request for snippet-style syntax support.

Kind regards, - Dylan