Index on file change (#1785)
* Reload the submenu items when the context provider data is refreshed * update version * Just call refreshSubmenuItems * remove log statements * cleanup * Remove the Promise declaration * Copy currentFiles to a new dict since we're going to mutate it Don't mutate the caller's currentFiles unexpectedly * Remove reIndexFile and just call index/forceReIndex * We MUST await the refreshCodebaseIndex call * Expose send on core * remove unused import * Reindex the workspaces on save * Call core.send Ideally, we can implement externalRequest on the webview later so we don't have to expose messenger to the VSCode extension * Always refreshSubmenuItems in refreshCodebaseIndex * whitespace * Change messenger back to private
This commit is contained in:
parent
e0079a4372
commit
a758d75c4a
6 changed files with 24 additions and 9 deletions
1
binary/package-lock.json
generated
1
binary/package-lock.json
generated
|
|
@ -109,6 +109,7 @@
|
|||
"eslint": "^8",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"jest": "^29.7.0",
|
||||
"myers-diff": "^2.1.0",
|
||||
"onnxruntime-common": "1.14.0",
|
||||
"onnxruntime-web": "1.14.0",
|
||||
"ts-jest": "^29.1.1"
|
||||
|
|
|
|||
12
core/core.ts
12
core/core.ts
|
|
@ -66,6 +66,14 @@ export class Core {
|
|||
return this.messenger.invoke(messageType, data);
|
||||
}
|
||||
|
||||
send<T extends keyof FromCoreProtocol>(
|
||||
messageType: T,
|
||||
data: FromCoreProtocol[T][0],
|
||||
messageId?: string,
|
||||
): string {
|
||||
return this.messenger.send(messageType, data);
|
||||
}
|
||||
|
||||
// TODO: It shouldn't actually need an IDE type, because this can happen
|
||||
// through the messenger (it does in the case of any non-VS Code IDEs already)
|
||||
constructor(
|
||||
|
|
@ -615,7 +623,7 @@ export class Core {
|
|||
});
|
||||
on("index/forceReIndex", async (msg) => {
|
||||
const dirs = msg.data ? [msg.data] : await this.ide.getWorkspaceDirs();
|
||||
this.refreshCodebaseIndex(dirs);
|
||||
await this.refreshCodebaseIndex(dirs);
|
||||
});
|
||||
on("index/setPaused", (msg) => {
|
||||
new GlobalContext().update("indexingPaused", msg.data);
|
||||
|
|
@ -651,6 +659,8 @@ export class Core {
|
|||
this.messenger.request("indexProgress", update);
|
||||
this.indexingState = update;
|
||||
}
|
||||
|
||||
this.messenger.send("refreshSubmenuItems", undefined);
|
||||
}
|
||||
|
||||
private async shouldReindexDocsOnNewEmbeddingsProvider(
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ async function getAddRemoveForTag(
|
|||
]
|
||||
> {
|
||||
const newLastUpdatedTimestamp = Date.now();
|
||||
const files = { ...currentFiles };
|
||||
|
||||
const saved = await getSavedItemsForTag(tag);
|
||||
|
||||
|
|
@ -149,12 +150,12 @@ async function getAddRemoveForTag(
|
|||
for (const item of saved) {
|
||||
const { lastUpdated, ...pathAndCacheKey } = item;
|
||||
|
||||
if (currentFiles[item.path] === undefined) {
|
||||
if (files[item.path] === undefined) {
|
||||
// Was indexed, but no longer exists. Remove
|
||||
remove.push(pathAndCacheKey);
|
||||
} else {
|
||||
// Exists in old and new, so determine whether it was updated
|
||||
if (lastUpdated < currentFiles[item.path]) {
|
||||
if (lastUpdated < files[item.path]) {
|
||||
// Change was made after last update
|
||||
const newHash = calculateHash(await readFile(pathAndCacheKey.path));
|
||||
if (pathAndCacheKey.cacheKey !== newHash) {
|
||||
|
|
@ -171,14 +172,14 @@ async function getAddRemoveForTag(
|
|||
}
|
||||
|
||||
// Remove so we can check leftovers afterward
|
||||
delete currentFiles[item.path];
|
||||
delete files[item.path];
|
||||
}
|
||||
}
|
||||
|
||||
// Any leftover in current files need to be added
|
||||
add.push(
|
||||
...(await Promise.all(
|
||||
Object.keys(currentFiles).map(async (path) => {
|
||||
Object.keys(files).map(async (path) => {
|
||||
const fileContents = await readFile(path);
|
||||
return { path, cacheKey: calculateHash(fileContents) };
|
||||
}),
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.186",
|
||||
"version": "0.9.189",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.186",
|
||||
"version": "0.9.189",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"version": "0.9.186",
|
||||
"version": "0.9.189",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ export class VsCodeExtension {
|
|||
this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
vscode.workspace.onDidSaveTextDocument((event) => {
|
||||
vscode.workspace.onDidSaveTextDocument(async (event) => {
|
||||
// Listen for file changes in the workspace
|
||||
const filepath = event.uri.fsPath;
|
||||
|
||||
|
|
@ -254,6 +254,9 @@ export class VsCodeExtension {
|
|||
) {
|
||||
// Update embeddings! (TODO)
|
||||
}
|
||||
|
||||
// Reindex the workspaces
|
||||
this.core.invoke("index/forceReIndex", undefined);
|
||||
});
|
||||
|
||||
// When GitHub sign-in status changes, reload config
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue