Vscode: SCM: Support `scmResourceState` in `when` clauses

Created on 3 Dec 2019  路  11Comments  路  Source: microsoft/vscode

See also #27946 for a related request/question.

The SCM API described here allows you to conditionally add commands to the SCM menus based on the scmProvider and scmResourceGroup, but not based on the scmResourceState.

Conditions on the scmResourceState would be valuable for mercurial extensions (which differentiates between behavior for modified files vs. added files vs. untracked files) without needing to use separate groups for all of them.

api api-finalization author-verification-requested feature-request insiders-released on-release-notes scm verification-needed verified

Most helpful comment

@joaomoreno if it helps I can verify it is working in today's insiders build:

recording (5)

All 11 comments

Here's an example of how specific commands make the SCM more intuitive for the user

For a modified file:

  • Revert: undo changes
  • Remove --force: remove the file even though it is modified

For an added file:

  • Untrack: forget the add (hg forget == hg revert == hg remove --force)

For a removed file:

  • Restore: restore the file

Using terms instead like revert or remove may be confusing for the user based on the resource state

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

I'm not sure if this will reach 20 upvotes because the people upvoting this will mostly be limited to scm provider extension developers, but this would be a big deal for the perforce extension (or at least my fork of it as the original is not really being updated)

Files in perforce can be shelved, and these are represented in the extension with an additional ResourceState for the shelved file. However the set of commands you can run on a shelved file is very different to the set of commands you can run on a normal file. At the minute, the menu is cluttered up with both, and there's no way to prevent this.

In the image below we have both "revert file" and "delete shelved file" but they are mutually exclusive and one will always show an error
image001

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding

We also need it to add/remove menu conditionally on ScmResourceGroup or ScmResource. It will help us organize our menu efficiently

Agree, please fix this issue!

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Verified in source by having the built-in git provider's resource implementing a contextValue and contributing a command to it:

      "scm/resourceState/context": [
        {
          "command": "xy.hello",
          "when": "scmResourceState == modified"
        },

This bug has been fixed in to the latest release of VS Code Insiders!

@DavidGoldman, you can help us out by confirming things are working as expected in the latest Insiders release. If things look good, please leave a comment with the text /verified to let us know. If not, please ensure you're on version 9e505675670d65138405321a60b0df4ddec28799 of Insiders (today's or later - you can use Help: About in the command pallete to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@DavidGoldman Could you verify this issue? Please check the previous comment for instructions. Thanks!

@joaomoreno if it helps I can verify it is working in today's insiders build:

recording (5)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

v-pavanp picture v-pavanp  路  3Comments

chrisdias picture chrisdias  路  3Comments

curtw picture curtw  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments