From 3f908ae4d94862a511c249d214ef97cacb93e57b Mon Sep 17 00:00:00 2001 From: Naman Kumar Date: Thu, 9 Jan 2025 16:22:31 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20repo=20name=20resolver=20cache=20miss=20d?= =?UTF-8?q?ue=20to=20using=20separate=20RepoNameResol=E2=80=A6=20(#6570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were creating a separate instance of the RepoNameResolver which was causing cache miss and in return making graphql calls to fetch the repo name. RepoNameResolver internally maintains an LRU and is supposed to be a singelton. ## Test plan - monitor network to check getRepoName queries are not made everytime you press @. - ## Changelog --- vscode/src/editor/utils/editor-context.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vscode/src/editor/utils/editor-context.ts b/vscode/src/editor/utils/editor-context.ts index 87b04b95ff2f..fe901a54476b 100644 --- a/vscode/src/editor/utils/editor-context.ts +++ b/vscode/src/editor/utils/editor-context.ts @@ -31,7 +31,7 @@ import { import { URI } from 'vscode-uri' import { getOpenTabsUris } from '.' import { toVSCodeRange } from '../../common/range' -import { RepoNameResolver } from '../../repository/repo-name-resolver' +import { repoNameResolver } from '../../repository/repo-name-resolver' import { findWorkspaceFiles } from './findWorkspaceFiles' // Some matches we don't want to ignore because they might be valid code (for example `bin/` in Dart) @@ -319,7 +319,6 @@ async function createContextFileFromUri( symbolName?: string ): Promise { const range = toRangeData(selectionRange) - const repoNameResolver = new RepoNameResolver() const repoNames = await firstValueFrom(repoNameResolver.getRepoNamesContainingUri(uri)) const repoName: string = Array.isArray(repoNames) ? repoNames[0] : repoNames.toString()