Skip to content

Commit

Permalink
Fix folder icon for chat (#241514)
Browse files Browse the repository at this point in the history
The LLM doesn't necessarily write a path that ends in /. Could patch it up in the tool but relying on stat is better.
  • Loading branch information
roblourens authored Feb 21, 2025
1 parent 72329c8 commit 4e45baa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,29 @@ export class InlineAnchorWidget extends Disposable {
`${label}#${location.range.startLineNumber}-${location.range.endLineNumber}` :
label;

const fileKind = location.uri.path.endsWith('/') ? FileKind.FOLDER : FileKind.FILE;
let fileKind = location.uri.path.endsWith('/') ? FileKind.FOLDER : FileKind.FILE;
const recomputeIconClasses = () => getIconClasses(modelService, languageService, location.uri, fileKind, fileKind === FileKind.FOLDER && !themeService.getFileIconTheme().hasFolderIcons ? FolderThemeIcon : undefined);

iconClasses = recomputeIconClasses();

this._register(themeService.onDidFileIconThemeChange(() => {
const refreshIconClasses = () => {
iconEl.classList.remove(...iconClasses);
iconClasses = recomputeIconClasses();
iconEl.classList.add(...iconClasses);
};

this._register(themeService.onDidFileIconThemeChange(() => {
refreshIconClasses();
}));

const isFolderContext = ExplorerFolderContext.bindTo(contextKeyService);
fileService.stat(location.uri)
.then(stat => {
isFolderContext.set(stat.isDirectory);
if (stat.isDirectory) {
fileKind = FileKind.FOLDER;
refreshIconClasses();
}
})
.catch(() => { });

Expand Down

0 comments on commit 4e45baa

Please sign in to comment.