@@ -122,7 +122,9 @@ export class Remote {
122
122
123
123
const disposables : vscode . Disposable [ ] = [ ]
124
124
// Register before connection so the label still displays!
125
- disposables . push ( this . registerLabelFormatter ( `${ this . storage . workspace . owner_name } /${ this . storage . workspace . name } ` ) )
125
+ disposables . push (
126
+ this . registerLabelFormatter ( remoteAuthority , this . storage . workspace . owner_name , this . storage . workspace . name ) ,
127
+ )
126
128
127
129
let buildComplete : undefined | ( ( ) => void )
128
130
if ( this . storage . workspace . latest_build . status === "stopped" ) {
@@ -420,14 +422,11 @@ export class Remote {
420
422
} )
421
423
422
424
// Register the label formatter again because SSH overrides it!
423
- let label = `${ this . storage . workspace . owner_name } /${ this . storage . workspace . name } `
424
- if ( agents . length > 1 ) {
425
- label += `/${ agent . name } `
426
- }
427
-
425
+ const workspace = this . storage . workspace
426
+ const agentName = agents . length > 1 ? agent . name : undefined
428
427
disposables . push (
429
428
vscode . extensions . onDidChange ( ( ) => {
430
- disposables . push ( this . registerLabelFormatter ( label ) )
429
+ disposables . push ( this . registerLabelFormatter ( remoteAuthority , workspace . owner_name , workspace . name , agentName ) )
431
430
} ) ,
432
431
)
433
432
@@ -679,14 +678,34 @@ export class Remote {
679
678
await vscode . commands . executeCommand ( "workbench.action.reloadWindow" )
680
679
}
681
680
682
- private registerLabelFormatter ( suffix : string ) : vscode . Disposable {
681
+ private registerLabelFormatter (
682
+ remoteAuthority : string ,
683
+ owner : string ,
684
+ workspace : string ,
685
+ agent ?: string ,
686
+ ) : vscode . Disposable {
687
+ // VS Code splits based on the separator when displaying the label
688
+ // in a recently opened dialog. If the workspace suffix contains /,
689
+ // then it'll visually display weird:
690
+ // "/home/kyle [Coder: kyle/workspace]" displays as "workspace] /home/kyle [Coder: kyle"
691
+ // For this reason, we use a different / that visually appears the
692
+ // same on non-monospace fonts "∕".
693
+ let suffix = `Coder: ${ owner } ∕${ workspace } `
694
+ if ( agent ) {
695
+ suffix += `∕${ agent } `
696
+ }
697
+ // VS Code caches resource label formatters in it's global storage SQLite database
698
+ // under the key "memento/cachedResourceLabelFormatters2".
683
699
return this . vscodeProposed . workspace . registerResourceLabelFormatter ( {
684
700
scheme : "vscode-remote" ,
701
+ // authority is optional but VS Code prefers formatters that most
702
+ // accurately match the requested authority, so we include it.
703
+ authority : remoteAuthority ,
685
704
formatting : {
686
705
label : "${path}" ,
687
706
separator : "/" ,
688
707
tildify : true ,
689
- workspaceSuffix : `Coder: ${ suffix } ` ,
708
+ workspaceSuffix : suffix ,
690
709
} ,
691
710
} )
692
711
}
0 commit comments