From f9c05273787140cfb4e8c3dcb06714e71bd6dcd1 Mon Sep 17 00:00:00 2001 From: Dmitriy Vasyura Date: Tue, 23 Dec 2025 12:12:24 -0800 Subject: [PATCH 1/2] Disable explorer.compactFolders when accessibility mode is turned on --- .../files/browser/views/explorerView.ts | 18 ++++++++- .../files/test/browser/explorerView.test.ts | 37 +++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index bef572b125a0c..5b115684ac0d6 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -55,6 +55,7 @@ import { EditorOpenSource } from '../../../../../platform/editor/common/editor.j import { ResourceMap } from '../../../../../base/common/map.js'; import { AbstractTreePart } from '../../../../../base/browser/ui/tree/abstractTree.js'; import { IHoverService } from '../../../../../platform/hover/browser/hover.js'; +import { IAccessibilityService } from '../../../../../platform/accessibility/common/accessibility.js'; function hasExpandedRootChild(tree: WorkbenchCompressibleAsyncDataTree, treeInput: ExplorerItem[]): boolean { @@ -213,7 +214,8 @@ export class ExplorerView extends ViewPane implements IExplorerView { @IFileService private readonly fileService: IFileService, @IUriIdentityService private readonly uriIdentityService: IUriIdentityService, @ICommandService private readonly commandService: ICommandService, - @IOpenerService openerService: IOpenerService + @IOpenerService openerService: IOpenerService, + @IAccessibilityService private readonly accessibilityService: IAccessibilityService ) { super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, hoverService); @@ -448,7 +450,14 @@ export class ExplorerView extends ViewPane implements IExplorerView { this._register(createFileIconThemableTreeContainerScope(container, this.themeService)); - const isCompressionEnabled = () => this.configurationService.getValue('explorer.compactFolders'); + const isCompressionEnabled = () => { + const configValue = this.configurationService.getValue('explorer.compactFolders'); + // Disable compact folders when screen reader is optimized for better accessibility + if (this.accessibilityService.isScreenReaderOptimized()) { + return false; + } + return configValue; + }; const getFileNestingSettings = (item?: ExplorerItem) => this.configurationService.getValue({ resource: item?.root.resource }).explorer.fileNesting; @@ -511,6 +520,11 @@ export class ExplorerView extends ViewPane implements IExplorerView { const onDidChangeCompressionConfiguration = Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('explorer.compactFolders')); this._register(onDidChangeCompressionConfiguration(_ => this.tree.updateOptions({ compressionEnabled: isCompressionEnabled() }))); + // Update compression when screen reader mode changes + this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => { + this.tree.updateOptions({ compressionEnabled: isCompressionEnabled() }); + })); + // Bind context keys FilesExplorerFocusedContext.bindTo(this.tree.contextKeyService); ExplorerFocusedContext.bindTo(this.tree.contextKeyService); diff --git a/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts b/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts index 7a531dd70f103..c3abb981361b6 100644 --- a/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts +++ b/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts @@ -15,6 +15,7 @@ import { DisposableStore } from '../../../../../base/common/lifecycle.js'; import { provideDecorations } from '../../browser/views/explorerDecorationsProvider.js'; import { TestConfigurationService } from '../../../../../platform/configuration/test/common/testConfigurationService.js'; import { NullFilesConfigurationService, TestFileService } from '../../../../test/common/workbenchTestServices.js'; +import { TestAccessibilityService } from '../../../../../platform/accessibility/test/common/testAccessibilityService.js'; suite('Files - ExplorerView', () => { @@ -120,4 +121,40 @@ suite('Files - ExplorerView', () => { navigationController.setIndex(44); assert.strictEqual(navigationController.current, s2); }); + + test('compact folders disabled when screen reader optimized', function () { + const configService = new TestConfigurationService(); + configService.setUserConfiguration('explorer', { compactFolders: true }); + + // Test with screen reader disabled - compact folders should be enabled + const testAccessibilityServiceOff = new class extends TestAccessibilityService { + override isScreenReaderOptimized(): boolean { return false; } + }(); + + // Simulate the isCompressionEnabled function from ExplorerView + const isCompressionEnabledOff = () => { + const configValue = configService.getValue('explorer.compactFolders'); + if (testAccessibilityServiceOff.isScreenReaderOptimized()) { + return false; + } + return configValue; + }; + + assert.strictEqual(isCompressionEnabledOff(), true, 'Compact folders should be enabled when screen reader is off'); + + // Test with screen reader enabled - compact folders should be disabled + const testAccessibilityServiceOn = new class extends TestAccessibilityService { + override isScreenReaderOptimized(): boolean { return true; } + }(); + + const isCompressionEnabledOn = () => { + const configValue = configService.getValue('explorer.compactFolders'); + if (testAccessibilityServiceOn.isScreenReaderOptimized()) { + return false; + } + return configValue; + }; + + assert.strictEqual(isCompressionEnabledOn(), false, 'Compact folders should be disabled when screen reader is optimized'); + }); }); From 189e08e9e4e0542c280ce98ce833b483d1d7a59f Mon Sep 17 00:00:00 2001 From: Dmitriy Vasyura Date: Tue, 23 Dec 2025 12:14:01 -0800 Subject: [PATCH 2/2] Revert test change --- .../files/test/browser/explorerView.test.ts | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts b/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts index c3abb981361b6..7a531dd70f103 100644 --- a/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts +++ b/src/vs/workbench/contrib/files/test/browser/explorerView.test.ts @@ -15,7 +15,6 @@ import { DisposableStore } from '../../../../../base/common/lifecycle.js'; import { provideDecorations } from '../../browser/views/explorerDecorationsProvider.js'; import { TestConfigurationService } from '../../../../../platform/configuration/test/common/testConfigurationService.js'; import { NullFilesConfigurationService, TestFileService } from '../../../../test/common/workbenchTestServices.js'; -import { TestAccessibilityService } from '../../../../../platform/accessibility/test/common/testAccessibilityService.js'; suite('Files - ExplorerView', () => { @@ -121,40 +120,4 @@ suite('Files - ExplorerView', () => { navigationController.setIndex(44); assert.strictEqual(navigationController.current, s2); }); - - test('compact folders disabled when screen reader optimized', function () { - const configService = new TestConfigurationService(); - configService.setUserConfiguration('explorer', { compactFolders: true }); - - // Test with screen reader disabled - compact folders should be enabled - const testAccessibilityServiceOff = new class extends TestAccessibilityService { - override isScreenReaderOptimized(): boolean { return false; } - }(); - - // Simulate the isCompressionEnabled function from ExplorerView - const isCompressionEnabledOff = () => { - const configValue = configService.getValue('explorer.compactFolders'); - if (testAccessibilityServiceOff.isScreenReaderOptimized()) { - return false; - } - return configValue; - }; - - assert.strictEqual(isCompressionEnabledOff(), true, 'Compact folders should be enabled when screen reader is off'); - - // Test with screen reader enabled - compact folders should be disabled - const testAccessibilityServiceOn = new class extends TestAccessibilityService { - override isScreenReaderOptimized(): boolean { return true; } - }(); - - const isCompressionEnabledOn = () => { - const configValue = configService.getValue('explorer.compactFolders'); - if (testAccessibilityServiceOn.isScreenReaderOptimized()) { - return false; - } - return configValue; - }; - - assert.strictEqual(isCompressionEnabledOn(), false, 'Compact folders should be disabled when screen reader is optimized'); - }); });