vscode-perforce icon indicating copy to clipboard operation
vscode-perforce copied to clipboard

Support activeRepositoryBranchName

Open Skylark13 opened this issue 1 year ago • 2 comments

Hello,

vscode 1.87 adds a way to customize the window title and add the active repository name and active repository branch name to it. See https://code.visualstudio.com/updates/v1_87#_include-repository-or-branch-name-in-the-window-title

I tried to add this and it doesn't work on a perforce repo, possibly there needs to be code added to the extension to support this? Sadly the release notes don't mention if this is only currently supported in the git source control provider and if extensions for other source control providers could be updated to support it.

I hope it's not too much trouble to add, it would be useful! Thanks in advance.

Skylark13 avatar Feb 29 '24 15:02 Skylark13

Hi,

thanks for raising - I don't have a vscode w/ perforce install handy right now but I had a look at the vscode source code and without testing it, from what I can see it should do something if you add in ${activeRepositoryName}, but probably not what you want.

Partly for my reference but also to record what's happening:

The new variables were added in microsoft/vscode#204393

specifically on these lines https://github.com/microsoft/vscode/pull/204393/files#diff-d782071bf39eaa9b2557326bf18c2deebd09313b6c38146b0a3cb9ef65e94794R327-R329

we are passing in the label here https://github.com/mjcrouch/vscode-perforce/blob/7bd13fd4e650fc98e86bf147d4e09968bbeaf6a9/src/ScmProvider.ts#L129 which should ultimately reach the provider:

it gets passed through to $registerSourceControl here https://github.com/microsoft/vscode/blob/00abefa3e27ee1866cf6a6ac825578c1ddafd32c/src/vs/workbench/api/common/extHostSCM.ts#L691 , creating a MainThreadSCMProvider (implements ISCMProvider)

and this returns a name here https://github.com/microsoft/vscode/blob/dff6d9f391dd448ca92463e755ca34f46fcc5843/src/vs/workbench/api/browser/mainThreadSCM.ts#L211

get name(): string { return this._name ?? this._label; }

However at this point I should just test it and see what it does - It looks like since it's preferencing _name over _label the name will just end up at best being the name of the folder (since that's what _name is set to that in the constructor) and not something useful like the name of the perforce client

I don't see how we could supply any kind of custom name here when using a client root folder. (even if we can, currently we're just passing "Perforce" as the label for everything and this needs some updating as per #263)

So in short, not sure if it's going to be practical without some more changes in the core vscode but I would have to look a bit further.

(also when it comes to branches, not sure what we could do that would make sense in the context of perforce - also not sure where it's getting that info from without diving deeper)

mjcrouch avatar Feb 29 '24 16:02 mjcrouch

You're right, ${activeRepositoryName} gives the workspace root folder, it looks like. So that part does do something, maybe it needs to be adjusted to do something different though (repository name would be what in perforce parlance, since a workspace can have lots of folder mappings... probably as you said client name would be more useful than workspace root folder).

Ideally we could get ${activeRepositoryBranchName} to work too, that would be the most useful to me, since I switch branches (or streams) in the same workspace pretty often and it would be useful to see at a glance which branch I'm editing files for at the moment.

Skylark13 avatar Feb 29 '24 17:02 Skylark13