Skip to content

Commit

Permalink
Don't add duplicate workspace folders (#3007)
Browse files Browse the repository at this point in the history
When we receive the initialization message from the client, only add the
workspace folders if they don't already exist. Previously, when the
agent service lived past the client lifespan, a subsequent client could
add a duplicate workspace folder.
  • Loading branch information
beyang authored Feb 2, 2024
1 parent 5e479cd commit 324751c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions agent/src/vscode-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,17 @@ let workspaceDocuments: WorkspaceDocuments | undefined
export function setWorkspaceDocuments(newWorkspaceDocuments: WorkspaceDocuments): void {
workspaceDocuments = newWorkspaceDocuments
if (newWorkspaceDocuments.workspaceRootUri) {
workspaceFolders.push({
name: 'Workspace Root',
uri: newWorkspaceDocuments.workspaceRootUri,
index: 0,
})
if (
!workspaceFolders
.map(wf => wf.uri.toString())
.includes(newWorkspaceDocuments.workspaceRootUri.toString())
) {
workspaceFolders.push({
name: 'Workspace Root',
uri: newWorkspaceDocuments.workspaceRootUri,
index: 0,
})
}
}
}

Expand Down

0 comments on commit 324751c

Please sign in to comment.