microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.7k stars 28.15k forks source link

Custom labels: support full file name variable #213197

Open bruce-c-liu opened 1 month ago

bruce-c-liu commented 1 month ago

Awesome feature! I've been using the following config: **: [${dirname}] ${filename}.${extname}

However, there's a slight problem with dot files. (e.g. .zshrc) The above config renders it as [prevDirectory] .zshrc., but I want it without the ending dot. Is that possible with the current levers?

benibenj commented 1 month ago

You could just add a second entry which catches these cases: **/.*: [${dirname}] ${filename} Does this work for you?

bruce-c-liu commented 1 month ago

Almost! However, .markdownlint.json renders as [<parent folder>] .markdownlint, whereas I want it with the extension: [<parent folder>] .markdownlint.json.

Essentially, I want to always render [<parent folder>] <full file name>. It seems providing a variable for the full file name would be the easiest solution here. 😅

benibenj commented 1 month ago

I see. We have this issue open #210166 which is regarding giving better access to parts of the filename when there are multiple extensions in it. I think it would make sense to also fix both of this issues together.

Leaving this issue open as it includes some good examples

bruce-c-liu commented 1 week ago

Quick followup that the updated ${extname(n)} syntax in the newest VSCode release (1.91.0) still doesn't address this issue.

My setting: **: [${dirname}] ${filename}.${extname}

File names:

Note how ${extname} is appended literally. I assume because it couldn't find a "real" extension?

Please consider my suggestion of "providing a variable for the full file name".

benibenj commented 1 week ago

I can see how having a fullFileName variable could make this easier. For the meantime, I think it should be possible to use these patterns to solve your scenario:

bruce-c-liu commented 1 week ago

Nice! That does indeed work for all my scenarios. Thanks!