From 4e45baad220bb80f2cb54eba11c8c0481c585bea Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 21 Feb 2025 11:27:57 -0800 Subject: [PATCH] Fix folder icon for chat (#241514) The LLM doesn't necessarily write a path that ends in /. Could patch it up in the tool but relying on stat is better. --- .../contrib/chat/browser/chatInlineAnchorWidget.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.ts b/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.ts index 6849ca7b081..0e19db104f3 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.ts @@ -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(() => { });