Skip to content

Conversation

mq200
Copy link
Contributor

@mq200 mq200 commented Sep 10, 2025

Description

When folders are moved/copied into a workpace in VSCode, they are not added to Continue's workspaceDirs (except for the 1st time folders are added, as an extension restart is triggered the 1st time).

The PR adds a listener to WorkspaceFoldersChangeEvent

From the VSCode API doc:

Note: this event will not fire if the first workspace folder is added, removed or changed, because in that case the currently executing extensions (including the one that listens to this event) will be terminated and restarted so that the (deprecated) rootPath property is updated to point to the first workspace folder.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-general-review or @continue-detailed-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Summary by cubic

Fixes missed reindexing when folders are added or removed in a VS Code workspace. The extension now refreshes workspace directories and updates the codebase index without a restart.

  • Bug Fixes
    • Listen to workspace folder changes and emit folders/changed with affected URIs.
    • Core invalidates walkDirCache, refreshes workspace dirs, and reindexes changed URIs when indexing is enabled.
    • Added refreshWorkspaceDirs to the IDE protocol and implemented it in VS Code and FileSystem IDEs.
    • VsCodeIdeUtils now refreshes its cached workspace directory list.

@mq200 mq200 requested a review from a team as a code owner September 10, 2025 22:03
@mq200 mq200 requested review from RomneyDa and removed request for a team September 10, 2025 22:03
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 10, 2025
Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mq200 this would be great.

  1. Can you implement this for jetbrains as well? or at least add a TODO comment to add to jetbrains?
  2. I think we could simplify the messaging a bit and remove the refreshWorkspaceDirs ide method. You can set workspace dirs within the VS Code IDE directly on folders changed.
  3. nitpick but I think the message could be named more clearly to mean workspace dirs rather than folders with a workspace dir. E.g. "workspaceDirsChanged"

his implementation

@@ -503,6 +503,14 @@ export class VsCodeExtension {
});
});

vscode.workspace.onDidChangeWorkspaceFolders(async (event) => {
this.core.invoke("folders/changed", {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can set ide utils.workspace dirs directly here. Might need to play with some private/public but I think worth not adding an extra message

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 11, 2025
@mq200
Copy link
Contributor Author

mq200 commented Sep 11, 2025

@RomneyDa okay, I'll add the changes for jetbrains in a separate PR shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants