Skip to content

Commit 0503a1e

Browse files
fix(history): enhance file item icon handling and pass file path in history view
1 parent e5b9b92 commit 0503a1e

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/ccpViewProvider.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ export class HistoryViewProvider implements vscode.TreeDataProvider<FileItem> {
203203
command: 'vscode.open',
204204
title: 'Open File',
205205
arguments: [vscode.Uri.file(file)]
206-
}
206+
},
207+
file // Pass the file path as the 4th parameter here
207208
);
208209
item.contextValue = 'historyItem';
209210
item.tooltip = file;
210211
item.description = path.dirname(file);
211-
item.filePath = file;
212212
items.push(item);
213213
});
214214

@@ -273,7 +273,8 @@ class FileItem extends vscode.TreeItem {
273273
this.contextValue = 'buttonItem';
274274
} else {
275275
if (filePath) {
276-
this.iconPath = vscode.ThemeIcon.File;
276+
// Replace generic file icon with language-specific icon
277+
this.iconPath = getFileIcon(filePath);
277278
this.contextValue = 'historyItem';
278279
}
279280
}
@@ -328,4 +329,15 @@ function identifyLanguage(extension: string): string {
328329
};
329330

330331
return extensionMap[extension.toLowerCase()] || 'plaintext';
332+
}
333+
334+
/**
335+
* Gets an appropriate icon for a file based on its extension
336+
* @param filePath - Path to the file
337+
* @returns ThemeIcon appropriate for the file type
338+
*/
339+
function getFileIcon(filePath: string): vscode.ThemeIcon {
340+
// Use file type theme icons that are guaranteed to exist in VS Code
341+
// This is a more reliable approach than language-specific icons
342+
return new vscode.ThemeIcon('file-code');
331343
}

0 commit comments

Comments
 (0)