Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdece118

Browse files
authored
fix: resolve odd label formatting for recently opened (#95)
1 parent9868091 commitdece118

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

‎src/remote.ts‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ export class Remote {
122122

123123
constdisposables:vscode.Disposable[]=[]
124124
// 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+
)
126128

127129
letbuildComplete:undefined|(()=>void)
128130
if(this.storage.workspace.latest_build.status==="stopped"){
@@ -420,14 +422,11 @@ export class Remote {
420422
})
421423

422424
// Register the label formatter again because SSH overrides it!
423-
letlabel=`${this.storage.workspace.owner_name}/${this.storage.workspace.name}`
424-
if(agents.length>1){
425-
label+=`/${agent.name}`
426-
}
427-
425+
constworkspace=this.storage.workspace
426+
constagentName=agents.length>1 ?agent.name :undefined
428427
disposables.push(
429428
vscode.extensions.onDidChange(()=>{
430-
disposables.push(this.registerLabelFormatter(label))
429+
disposables.push(this.registerLabelFormatter(remoteAuthority,workspace.owner_name,workspace.name,agentName))
431430
}),
432431
)
433432

@@ -679,14 +678,34 @@ export class Remote {
679678
awaitvscode.commands.executeCommand("workbench.action.reloadWindow")
680679
}
681680

682-
privateregisterLabelFormatter(suffix:string):vscode.Disposable{
681+
privateregisterLabelFormatter(
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+
letsuffix=`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".
683699
returnthis.vscodeProposed.workspace.registerResourceLabelFormatter({
684700
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,
685704
formatting:{
686705
label:"${path}",
687706
separator:"/",
688707
tildify:true,
689-
workspaceSuffix:`Coder:${suffix}`,
708+
workspaceSuffix:suffix,
690709
},
691710
})
692711
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp