diff --git a/.changeset/eleven-monkeys-watch.md b/.changeset/eleven-monkeys-watch.md new file mode 100644 index 00000000..7388a6e8 --- /dev/null +++ b/.changeset/eleven-monkeys-watch.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Prioritize active files in file context menu diff --git a/src/integrations/workspace/WorkspaceTracker.ts b/src/integrations/workspace/WorkspaceTracker.ts index 2072f911..d56f7f82 100644 --- a/src/integrations/workspace/WorkspaceTracker.ts +++ b/src/integrations/workspace/WorkspaceTracker.ts @@ -10,6 +10,14 @@ class WorkspaceTracker { private disposables: vscode.Disposable[] = [] private filePaths: Set = new Set() + private get activeFiles() { + return new Set( + vscode.window.tabGroups.activeTabGroup.tabs + .filter((tab) => tab.input instanceof vscode.TabInputText) + .map((tab) => (tab.input as vscode.TabInputText).uri.fsPath), + ) + } + constructor(private readonly postMessageToWebview: (message: ExtensionMessage) => Promise) { this.postMessageToWebview = postMessageToWebview this.registerListeners() @@ -36,6 +44,9 @@ class WorkspaceTracker { // Listen for file renaming this.disposables.push(vscode.workspace.onDidRenameFiles(this.onFilesRenamed.bind(this))) + // Listen for tab groups changes + this.disposables.push(vscode.window.tabGroups.onDidChangeTabs(this.workspaceDidUpdate.bind(this))) + /* An event that is emitted when a workspace folder is added or removed. **Note:** this event will not fire if the first workspace folder is added, removed or changed, @@ -86,7 +97,7 @@ class WorkspaceTracker { } this.postMessageToWebview({ type: "workspaceUpdated", - filePaths: Array.from(this.filePaths).map((file) => { + filePaths: Array.from(new Set([...this.activeFiles, ...this.filePaths])).map((file) => { const relativePath = path.relative(cwd, file).toPosix() return file.endsWith("/") ? relativePath + "/" : relativePath }),