fix file selection
This commit is contained in:
@@ -74,15 +74,30 @@ class PrompterTreeProvider implements vscode.TreeDataProvider<FileTreeItem> {
|
|||||||
|
|
||||||
toggleSelection(item: FileTreeItem): void {
|
toggleSelection(item: FileTreeItem): void {
|
||||||
const filePath = item.resourceUri.fsPath;
|
const filePath = item.resourceUri.fsPath;
|
||||||
|
console.log('Toggle selection called for:', filePath);
|
||||||
if (this.selectedFiles.has(filePath)) {
|
if (this.selectedFiles.has(filePath)) {
|
||||||
this.selectedFiles.delete(filePath);
|
this.removeFromSelection(item);
|
||||||
} else {
|
} else {
|
||||||
this.selectedFiles.add(filePath);
|
this.addToSelection(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addToSelection(item: FileTreeItem): void {
|
||||||
|
const filePath = item.resourceUri.fsPath;
|
||||||
|
this.selectedFiles.add(filePath);
|
||||||
|
console.log('Added file to selection, count:', this.selectedFiles.size);
|
||||||
|
this._onDidChangeTreeData.fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromSelection(item: FileTreeItem): void {
|
||||||
|
const filePath = item.resourceUri.fsPath;
|
||||||
|
this.selectedFiles.delete(filePath);
|
||||||
|
console.log('Removed file from selection, count:', this.selectedFiles.size);
|
||||||
this._onDidChangeTreeData.fire();
|
this._onDidChangeTreeData.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedFiles(): Set<string> {
|
getSelectedFiles(): Set<string> {
|
||||||
|
console.log('getSelectedFiles called, count:', this.selectedFiles.size);
|
||||||
return this.selectedFiles;
|
return this.selectedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,10 +166,25 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath;
|
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath;
|
||||||
const prompterTreeProvider = new PrompterTreeProvider(workspaceRoot);
|
const prompterTreeProvider = new PrompterTreeProvider(workspaceRoot);
|
||||||
|
|
||||||
// Register the TreeView
|
// Register the TreeView with checkbox support
|
||||||
const treeView = vscode.window.createTreeView('prompterView', {
|
const treeView = vscode.window.createTreeView('prompterView', {
|
||||||
treeDataProvider: prompterTreeProvider,
|
treeDataProvider: prompterTreeProvider,
|
||||||
showCollapseAll: true
|
showCollapseAll: true,
|
||||||
|
canSelectMany: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle checkbox changes
|
||||||
|
treeView.onDidChangeCheckboxState(e => {
|
||||||
|
console.log('Checkbox state changed');
|
||||||
|
for (const [item, state] of e.items) {
|
||||||
|
const fileItem = item as FileTreeItem;
|
||||||
|
console.log(`Checkbox changed for ${fileItem.resourceUri.fsPath} to ${state}`);
|
||||||
|
if (state === vscode.TreeItemCheckboxState.Checked) {
|
||||||
|
prompterTreeProvider.addToSelection(fileItem);
|
||||||
|
} else {
|
||||||
|
prompterTreeProvider.removeFromSelection(fileItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create XML edits toggle button
|
// Create XML edits toggle button
|
||||||
@@ -173,6 +203,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// Register command to toggle file selection
|
// Register command to toggle file selection
|
||||||
let toggleSelectionCommand = vscode.commands.registerCommand('prompter.toggleSelection', (item: FileTreeItem) => {
|
let toggleSelectionCommand = vscode.commands.registerCommand('prompter.toggleSelection', (item: FileTreeItem) => {
|
||||||
|
console.log('Toggle selection command triggered for:', item.resourceUri.fsPath);
|
||||||
prompterTreeProvider.toggleSelection(item);
|
prompterTreeProvider.toggleSelection(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -186,6 +217,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// Register command to generate prompt from selected files
|
// Register command to generate prompt from selected files
|
||||||
let generatePromptCommand = vscode.commands.registerCommand('prompter.generatePrompt', async () => {
|
let generatePromptCommand = vscode.commands.registerCommand('prompter.generatePrompt', async () => {
|
||||||
const selectedFiles = prompterTreeProvider.getSelectedFiles();
|
const selectedFiles = prompterTreeProvider.getSelectedFiles();
|
||||||
|
console.log('Generate prompt command triggered, selected files:', [...selectedFiles]);
|
||||||
if (selectedFiles.size === 0) {
|
if (selectedFiles.size === 0) {
|
||||||
vscode.window.showInformationMessage('Please select files first');
|
vscode.window.showInformationMessage('Please select files first');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user