Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow usage of filenamePart template in custom labels #213033

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bsShoham
Copy link
Contributor

@bsShoham bsShoham commented May 19, 2024

This pull requests add to the custom label service the option to accept a new template variable in the patterns, which allows to insert into the label each of the parts of the full file name (including the extension) separated by .

usage example:

settings.json:

    "workbench.editor.customLabels.enabled": true,
    "workbench.editor.customLabels.patterns": {
        "**/unit-tests/**/*.spec.*": "Test ${filenamePart(1)}",
        "**/e2e/**/*.e2e.spec.*": "Test ${filenamePart(2)} ${filenamePart(1)}",
    }

The results would be:
WORKSPACE/units-tests/users.spec.ts -> Test users
WORKSPACE/e2e/users.e2e.spec.ts -> Test e2e users

closes #210166

also fixes some small spelling mistakes.

@bsShoham
Copy link
Contributor Author

@bsShoham please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@bsShoham bsShoham force-pushed the dev/add-filename-part-custom-label-template branch from c441332 to 3ce177e Compare May 19, 2024 12:49
@benibenj
Copy link
Contributor

Thank you for creating a PR for this. I think it makes sense to tackle this case.
I see you want to introduce a variable filenamePart. I wonder if this might be a bit confusing.

I would propose the following:

  • filename: name of the file without any extension
  • extname: the entire extension
  • extname(N): a specific part of the extension starting from the back

Example path: src/main.ex1.ex2.ex3

  • filename: main
  • extname: ex1.ex2.ex3
  • extname(0): ex3
  • extname(1): ex2
  • extname(2): ex1
  • extname(3): This does not work and would show the template (${extname(3)}) to indicate to the user that his pattern/template is invalid

@bsShoham bsShoham force-pushed the dev/add-filename-part-custom-label-template branch from 3ce177e to ed1e1da Compare May 29, 2024 10:08
@benibenj benibenj added this to the June 2024 milestone May 29, 2024
@benibenj benibenj self-requested a review May 29, 2024 10:53
@bsShoham
Copy link
Contributor Author

@benibenj Thanks for the reply and the suggestions!
I've gone and made changes according to your proposal, would love it if you can have a look.

@benibenj
Copy link
Contributor

Thanks for making the changes!
We are currently preparing for the release next week (this means no more changes can go in) so I'll review this in June and we can make it part of the June release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Labels: improve ${extname} when file includes multiple extensions
2 participants