defining cache for opened files + making change in active editor update cache element recency

This commit is contained in:
adarshramiyer 2025-06-03 13:47:07 -07:00
parent d2a0db01eb
commit ad95e61ec0
5 changed files with 22 additions and 4 deletions

View file

@ -0,0 +1,14 @@
import QuickLRU from "quick-lru";
// The cache key and value are both a filepath string
type cacheElementType = string;
// maximum number of open files that can be cached
const MAX_NUM_OPEN_CONTEXT_FILES = 10;
export const openedFilesLruCache = new QuickLRU<
cacheElementType,
cacheElementType
>({
maxSize: MAX_NUM_OPEN_CONTEXT_FILES,
});

View file

@ -3,6 +3,7 @@ import * as URI from "uri-js";
import { v4 as uuidv4 } from "uuid";
import { CompletionProvider } from "./autocomplete/CompletionProvider";
import { openedFilesLruCache } from "./autocomplete/util/openedFilesLruCache";
import { ConfigHandler } from "./config/ConfigHandler";
import { SYSTEM_PROMPT_DOT_FILE } from "./config/getWorkspaceContinueRuleDotFiles";
import { addModel, deleteModel } from "./config/util";
@ -692,7 +693,10 @@ export class Core {
try {
const ignore = await shouldIgnore(filepath, this.ide);
if (!ignore) {
// Update the recently edited files cache
recentlyEditedFilesCache.set(filepath, filepath);
// Update the cache for opened files as well
openedFilesLruCache.set(filepath, filepath);
}
} catch (e) {
console.error(

View file

@ -199,7 +199,8 @@
"onnxruntime-common": "1.14.0",
"onnxruntime-web": "1.14.0",
"ts-jest": "^29.1.1",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"vitest": "^3.1.4"
},
"engines": {
"node": ">=20.19.0"

View file

@ -3,8 +3,6 @@ import { exec } from "node:child_process";
import { Range } from "core";
import { EXTENSION_NAME } from "core/control-plane/env";
import { GetGhTokenArgs } from "core/protocol/ide";
import { editConfigFile, getConfigJsonPath } from "core/util/paths";
import * as URI from "uri-js";
import * as vscode from "vscode";

3
gui/package-lock.json generated
View file

@ -203,7 +203,8 @@
"onnxruntime-common": "1.14.0",
"onnxruntime-web": "1.14.0",
"ts-jest": "^29.1.1",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"vitest": "^3.1.4"
},
"engines": {
"node": ">=20.19.0"