microsoft / vscode

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

Allow custom setting/control of workbench tab titles #43806

Closed DABH closed 3 months ago

DABH commented 6 years ago

Hi there,

In my project, I have files with quite long file names (beyond my control). This limits me to having 3-4 tabs show in my workbench at once. I would like to be able to rename these tabs, or control their label format myself, in order to have more condense tab titles and thus more easily navigate my tabs. This was roughly suggested by #21662 but was not really addressed by #12965 -- any of the options for workbench.editor.labelFormat still give me tab titles that are too long. Can workbench.editor.labelFormat be modified, for example, to optionally take a formatter lambda function we can provide? As just one example of a reasonable formatter one might write, it could be that you fix tab titles to 20 chars, and for long filenames you truncate and prepend with "...". Additionally, one might want to assign nickname/shorthand tab titles for commonly used files. Please pardon me if there is already a way to do this (would love to know how!), but if not, I'd sincerely appreciate considering this as a feature request.

Thanks!

hexvictor commented 1 year ago

In my case I'm following a Next.js tutorial and it seems my files need to be page.jsx You can see how this can be confusing. I can see the folder the file is in, this could help me identify which one I need but I'd love to be able to nickname file's tab titles! This would solve my problem, because I could rename this page.jsx tab title to RepoPage making it so much easy to find it! I was imagining right clicking the tab and placing a nickname on it. Every time that specific file opens up, it would be renamed to what I had set previously. image

nico-martinucci commented 1 year ago

Would love to see this feature as well, particularly the "directory is more meaningful than file name" change. Big thanks to @DABH and @stefcameron for bringing this to light and digging into this, and huge thanks to @mehanix for putting together what seems like an effective and totally reasonable solution.

It seems like this pattern isn't going away anytime soon, and is continuing to be reinforced with every new framework/update that's coming out (like @howtovictor 's not on Next). This seems like a no-brainer add - does anyone have any steam left in them to try to get this over the finish line??

Aetherinox commented 6 months ago

Have interest in this as well. Just being able to give a tab a custom name alone would be a HUGE positive.

developer-don commented 5 months ago

The Custom Labels feature in version 1.88 released March of this year does what I need. I haven't reviewed this thread in a few years, so unsure that it'll be what everyone here needs, but I'm happy. 🙂 https://code.visualstudio.com/updates/v1_88#_custom-labels-for-open-editors

image
benibenj commented 3 months ago

Custom Labels allows you to change the label of each editor. @DABH does this feature solve this issue?

VSCodeTriageBot commented 3 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

DABH commented 3 months ago

@benibenj Thanks for noting this new feature! It’s really close to what I had in mind all those years ago, but not quite as general. I was proposing just let users specify a function that takes the file path and returns some custom label. What the team has implemented has a few things you can substitute but doesn’t allow arbitrary transforms on the label as far as I can tell, like, I couldn’t write an expression/function like “${filename}.toUpper()”. Maybe the current solution meets most people’s needs, but I’m tempted to leave this issue open since the original goal of supporting some custom function for renaming labels still isn’t there? Wdyt?

benibenj commented 3 months ago

We are open to expand the templating language we use if necessary, but we won't be allowing users to provide actual code. For example, we could consider doing something like $LOWER{filename} (not sure what the exact syntax would be) in the future, but I haven't seen any demand for something like this yet.