abd191dbb8f813a54c329e0e23f98273ac705567d732037d302b9d29b72c01089d77c0fba99c79d7c9a3f9d437f6581cbe584e0f00b011d7063548c312e506 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. var __param = (this && this.__param) || function (paramIndex, decorator) {
  12. return function (target, key) { decorator(target, key, paramIndex); }
  13. };
  14. import { createStyleSheet } from '../../../base/browser/dom.js';
  15. import { PagedList } from '../../../base/browser/ui/list/listPaging.js';
  16. import { DefaultStyleController, isSelectionRangeChangeEvent, isSelectionSingleChangeEvent, List, TypeNavigationMode } from '../../../base/browser/ui/list/listWidget.js';
  17. import { Table } from '../../../base/browser/ui/table/tableWidget.js';
  18. import { TreeFindMode } from '../../../base/browser/ui/tree/abstractTree.js';
  19. import { AsyncDataTree, CompressibleAsyncDataTree } from '../../../base/browser/ui/tree/asyncDataTree.js';
  20. import { DataTree } from '../../../base/browser/ui/tree/dataTree.js';
  21. import { CompressibleObjectTree, ObjectTree } from '../../../base/browser/ui/tree/objectTree.js';
  22. import { Emitter, Event } from '../../../base/common/event.js';
  23. import { combinedDisposable, Disposable, DisposableStore, dispose, toDisposable } from '../../../base/common/lifecycle.js';
  24. import { localize } from '../../../nls.js';
  25. import { IConfigurationService } from '../../configuration/common/configuration.js';
  26. import { Extensions as ConfigurationExtensions } from '../../configuration/common/configurationRegistry.js';
  27. import { ContextKeyExpr, IContextKeyService, RawContextKey } from '../../contextkey/common/contextkey.js';
  28. import { InputFocusedContextKey } from '../../contextkey/common/contextkeys.js';
  29. import { IContextViewService } from '../../contextview/browser/contextView.js';
  30. import { createDecorator, IInstantiationService } from '../../instantiation/common/instantiation.js';
  31. import { IKeybindingService } from '../../keybinding/common/keybinding.js';
  32. import { Registry } from '../../registry/common/platform.js';
  33. import { attachListStyler, computeStyles, defaultListStyles } from '../../theme/common/styler.js';
  34. import { IThemeService } from '../../theme/common/themeService.js';
  35. export const IListService = createDecorator('listService');
  36. let ListService = class ListService {
  37. constructor(_themeService) {
  38. this._themeService = _themeService;
  39. this.disposables = new DisposableStore();
  40. this.lists = [];
  41. this._lastFocusedWidget = undefined;
  42. this._hasCreatedStyleController = false;
  43. }
  44. get lastFocusedList() {
  45. return this._lastFocusedWidget;
  46. }
  47. setLastFocusedList(widget) {
  48. var _a, _b;
  49. if (widget === this._lastFocusedWidget) {
  50. return;
  51. }
  52. (_a = this._lastFocusedWidget) === null || _a === void 0 ? void 0 : _a.getHTMLElement().classList.remove('last-focused');
  53. this._lastFocusedWidget = widget;
  54. (_b = this._lastFocusedWidget) === null || _b === void 0 ? void 0 : _b.getHTMLElement().classList.add('last-focused');
  55. }
  56. register(widget, extraContextKeys) {
  57. if (!this._hasCreatedStyleController) {
  58. this._hasCreatedStyleController = true;
  59. // create a shared default tree style sheet for performance reasons
  60. const styleController = new DefaultStyleController(createStyleSheet(), '');
  61. this.disposables.add(attachListStyler(styleController, this._themeService));
  62. }
  63. if (this.lists.some(l => l.widget === widget)) {
  64. throw new Error('Cannot register the same widget multiple times');
  65. }
  66. // Keep in our lists list
  67. const registeredList = { widget, extraContextKeys };
  68. this.lists.push(registeredList);
  69. // Check for currently being focused
  70. if (widget.getHTMLElement() === document.activeElement) {
  71. this.setLastFocusedList(widget);
  72. }
  73. return combinedDisposable(widget.onDidFocus(() => this.setLastFocusedList(widget)), toDisposable(() => this.lists.splice(this.lists.indexOf(registeredList), 1)), widget.onDidDispose(() => {
  74. this.lists = this.lists.filter(l => l !== registeredList);
  75. if (this._lastFocusedWidget === widget) {
  76. this.setLastFocusedList(undefined);
  77. }
  78. }));
  79. }
  80. dispose() {
  81. this.disposables.dispose();
  82. }
  83. };
  84. ListService = __decorate([
  85. __param(0, IThemeService)
  86. ], ListService);
  87. export { ListService };
  88. export const RawWorkbenchListFocusContextKey = new RawContextKey('listFocus', true);
  89. export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey('listSupportsMultiselect', true);
  90. export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey));
  91. export const WorkbenchListHasSelectionOrFocus = new RawContextKey('listHasSelectionOrFocus', false);
  92. export const WorkbenchListDoubleSelection = new RawContextKey('listDoubleSelection', false);
  93. export const WorkbenchListMultiSelection = new RawContextKey('listMultiSelection', false);
  94. export const WorkbenchListSelectionNavigation = new RawContextKey('listSelectionNavigation', false);
  95. export const WorkbenchListSupportsFind = new RawContextKey('listSupportsFind', true);
  96. export const WorkbenchTreeElementCanCollapse = new RawContextKey('treeElementCanCollapse', false);
  97. export const WorkbenchTreeElementHasParent = new RawContextKey('treeElementHasParent', false);
  98. export const WorkbenchTreeElementCanExpand = new RawContextKey('treeElementCanExpand', false);
  99. export const WorkbenchTreeElementHasChild = new RawContextKey('treeElementHasChild', false);
  100. export const WorkbenchTreeFindOpen = new RawContextKey('treeFindOpen', false);
  101. const WorkbenchListTypeNavigationModeKey = 'listTypeNavigationMode';
  102. /**
  103. * @deprecated in favor of WorkbenchListTypeNavigationModeKey
  104. */
  105. const WorkbenchListAutomaticKeyboardNavigationLegacyKey = 'listAutomaticKeyboardNavigation';
  106. function createScopedContextKeyService(contextKeyService, widget) {
  107. const result = contextKeyService.createScoped(widget.getHTMLElement());
  108. RawWorkbenchListFocusContextKey.bindTo(result);
  109. return result;
  110. }
  111. const multiSelectModifierSettingKey = 'workbench.list.multiSelectModifier';
  112. const openModeSettingKey = 'workbench.list.openMode';
  113. const horizontalScrollingKey = 'workbench.list.horizontalScrolling';
  114. const defaultFindModeSettingKey = 'workbench.list.defaultFindMode';
  115. /** @deprecated in favor of workbench.list.defaultFindMode */
  116. const keyboardNavigationSettingKey = 'workbench.list.keyboardNavigation';
  117. const treeIndentKey = 'workbench.tree.indent';
  118. const treeRenderIndentGuidesKey = 'workbench.tree.renderIndentGuides';
  119. const listSmoothScrolling = 'workbench.list.smoothScrolling';
  120. const mouseWheelScrollSensitivityKey = 'workbench.list.mouseWheelScrollSensitivity';
  121. const fastScrollSensitivityKey = 'workbench.list.fastScrollSensitivity';
  122. const treeExpandMode = 'workbench.tree.expandMode';
  123. function useAltAsMultipleSelectionModifier(configurationService) {
  124. return configurationService.getValue(multiSelectModifierSettingKey) === 'alt';
  125. }
  126. class MultipleSelectionController extends Disposable {
  127. constructor(configurationService) {
  128. super();
  129. this.configurationService = configurationService;
  130. this.useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  131. this.registerListeners();
  132. }
  133. registerListeners() {
  134. this._register(this.configurationService.onDidChangeConfiguration(e => {
  135. if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
  136. this.useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService);
  137. }
  138. }));
  139. }
  140. isSelectionSingleChangeEvent(event) {
  141. if (this.useAltAsMultipleSelectionModifier) {
  142. return event.browserEvent.altKey;
  143. }
  144. return isSelectionSingleChangeEvent(event);
  145. }
  146. isSelectionRangeChangeEvent(event) {
  147. return isSelectionRangeChangeEvent(event);
  148. }
  149. }
  150. function toWorkbenchListOptions(accessor, options) {
  151. var _a;
  152. const configurationService = accessor.get(IConfigurationService);
  153. const keybindingService = accessor.get(IKeybindingService);
  154. const disposables = new DisposableStore();
  155. const result = Object.assign(Object.assign({}, options), { keyboardNavigationDelegate: { mightProducePrintableCharacter(e) { return keybindingService.mightProducePrintableCharacter(e); } }, smoothScrolling: Boolean(configurationService.getValue(listSmoothScrolling)), mouseWheelScrollSensitivity: configurationService.getValue(mouseWheelScrollSensitivityKey), fastScrollSensitivity: configurationService.getValue(fastScrollSensitivityKey), multipleSelectionController: (_a = options.multipleSelectionController) !== null && _a !== void 0 ? _a : disposables.add(new MultipleSelectionController(configurationService)), keyboardNavigationEventFilter: createKeyboardNavigationEventFilter(keybindingService) });
  156. return [result, disposables];
  157. }
  158. let WorkbenchList = class WorkbenchList extends List {
  159. constructor(user, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, instantiationService) {
  160. const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
  161. const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, options);
  162. super(user, container, delegate, renderers, Object.assign(Object.assign(Object.assign({ keyboardSupport: false }, computeStyles(themeService.getColorTheme(), defaultListStyles)), workbenchListOptions), { horizontalScrolling }));
  163. this.disposables.add(workbenchListOptionsDisposable);
  164. this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
  165. this.themeService = themeService;
  166. this.listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
  167. this.listSupportsMultiSelect.set(options.multipleSelectionSupport !== false);
  168. const listSelectionNavigation = WorkbenchListSelectionNavigation.bindTo(this.contextKeyService);
  169. listSelectionNavigation.set(Boolean(options.selectionNavigation));
  170. this.listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
  171. this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
  172. this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
  173. this.horizontalScrolling = options.horizontalScrolling;
  174. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  175. this.disposables.add(this.contextKeyService);
  176. this.disposables.add(listService.register(this));
  177. if (options.overrideStyles) {
  178. this.updateStyles(options.overrideStyles);
  179. }
  180. this.disposables.add(this.onDidChangeSelection(() => {
  181. const selection = this.getSelection();
  182. const focus = this.getFocus();
  183. this.contextKeyService.bufferChangeEvents(() => {
  184. this.listHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  185. this.listMultiSelection.set(selection.length > 1);
  186. this.listDoubleSelection.set(selection.length === 2);
  187. });
  188. }));
  189. this.disposables.add(this.onDidChangeFocus(() => {
  190. const selection = this.getSelection();
  191. const focus = this.getFocus();
  192. this.listHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  193. }));
  194. this.disposables.add(configurationService.onDidChangeConfiguration(e => {
  195. if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
  196. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  197. }
  198. let options = {};
  199. if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
  200. const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
  201. options = Object.assign(Object.assign({}, options), { horizontalScrolling });
  202. }
  203. if (e.affectsConfiguration(listSmoothScrolling)) {
  204. const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
  205. options = Object.assign(Object.assign({}, options), { smoothScrolling });
  206. }
  207. if (e.affectsConfiguration(mouseWheelScrollSensitivityKey)) {
  208. const mouseWheelScrollSensitivity = configurationService.getValue(mouseWheelScrollSensitivityKey);
  209. options = Object.assign(Object.assign({}, options), { mouseWheelScrollSensitivity });
  210. }
  211. if (e.affectsConfiguration(fastScrollSensitivityKey)) {
  212. const fastScrollSensitivity = configurationService.getValue(fastScrollSensitivityKey);
  213. options = Object.assign(Object.assign({}, options), { fastScrollSensitivity });
  214. }
  215. if (Object.keys(options).length > 0) {
  216. this.updateOptions(options);
  217. }
  218. }));
  219. this.navigator = new ListResourceNavigator(this, Object.assign({ configurationService }, options));
  220. this.disposables.add(this.navigator);
  221. }
  222. updateOptions(options) {
  223. super.updateOptions(options);
  224. if (options.overrideStyles) {
  225. this.updateStyles(options.overrideStyles);
  226. }
  227. if (options.multipleSelectionSupport !== undefined) {
  228. this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
  229. }
  230. }
  231. updateStyles(styles) {
  232. var _a;
  233. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  234. this._styler = attachListStyler(this, this.themeService, styles);
  235. }
  236. dispose() {
  237. var _a;
  238. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  239. super.dispose();
  240. }
  241. };
  242. WorkbenchList = __decorate([
  243. __param(5, IContextKeyService),
  244. __param(6, IListService),
  245. __param(7, IThemeService),
  246. __param(8, IConfigurationService),
  247. __param(9, IInstantiationService)
  248. ], WorkbenchList);
  249. export { WorkbenchList };
  250. let WorkbenchPagedList = class WorkbenchPagedList extends PagedList {
  251. constructor(user, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, instantiationService) {
  252. const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
  253. const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, options);
  254. super(user, container, delegate, renderers, Object.assign(Object.assign(Object.assign({ keyboardSupport: false }, computeStyles(themeService.getColorTheme(), defaultListStyles)), workbenchListOptions), { horizontalScrolling }));
  255. this.disposables = new DisposableStore();
  256. this.disposables.add(workbenchListOptionsDisposable);
  257. this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
  258. this.themeService = themeService;
  259. this.horizontalScrolling = options.horizontalScrolling;
  260. this.listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
  261. this.listSupportsMultiSelect.set(options.multipleSelectionSupport !== false);
  262. const listSelectionNavigation = WorkbenchListSelectionNavigation.bindTo(this.contextKeyService);
  263. listSelectionNavigation.set(Boolean(options.selectionNavigation));
  264. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  265. this.disposables.add(this.contextKeyService);
  266. this.disposables.add(listService.register(this));
  267. if (options.overrideStyles) {
  268. this.updateStyles(options.overrideStyles);
  269. }
  270. if (options.overrideStyles) {
  271. this.disposables.add(attachListStyler(this, themeService, options.overrideStyles));
  272. }
  273. this.disposables.add(configurationService.onDidChangeConfiguration(e => {
  274. if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
  275. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  276. }
  277. let options = {};
  278. if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
  279. const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
  280. options = Object.assign(Object.assign({}, options), { horizontalScrolling });
  281. }
  282. if (e.affectsConfiguration(listSmoothScrolling)) {
  283. const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
  284. options = Object.assign(Object.assign({}, options), { smoothScrolling });
  285. }
  286. if (e.affectsConfiguration(mouseWheelScrollSensitivityKey)) {
  287. const mouseWheelScrollSensitivity = configurationService.getValue(mouseWheelScrollSensitivityKey);
  288. options = Object.assign(Object.assign({}, options), { mouseWheelScrollSensitivity });
  289. }
  290. if (e.affectsConfiguration(fastScrollSensitivityKey)) {
  291. const fastScrollSensitivity = configurationService.getValue(fastScrollSensitivityKey);
  292. options = Object.assign(Object.assign({}, options), { fastScrollSensitivity });
  293. }
  294. if (Object.keys(options).length > 0) {
  295. this.updateOptions(options);
  296. }
  297. }));
  298. this.navigator = new ListResourceNavigator(this, Object.assign({ configurationService }, options));
  299. this.disposables.add(this.navigator);
  300. }
  301. updateOptions(options) {
  302. super.updateOptions(options);
  303. if (options.overrideStyles) {
  304. this.updateStyles(options.overrideStyles);
  305. }
  306. if (options.multipleSelectionSupport !== undefined) {
  307. this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
  308. }
  309. }
  310. updateStyles(styles) {
  311. var _a;
  312. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  313. this._styler = attachListStyler(this, this.themeService, styles);
  314. }
  315. dispose() {
  316. var _a;
  317. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  318. this.disposables.dispose();
  319. super.dispose();
  320. }
  321. };
  322. WorkbenchPagedList = __decorate([
  323. __param(5, IContextKeyService),
  324. __param(6, IListService),
  325. __param(7, IThemeService),
  326. __param(8, IConfigurationService),
  327. __param(9, IInstantiationService)
  328. ], WorkbenchPagedList);
  329. export { WorkbenchPagedList };
  330. let WorkbenchTable = class WorkbenchTable extends Table {
  331. constructor(user, container, delegate, columns, renderers, options, contextKeyService, listService, themeService, configurationService, instantiationService) {
  332. const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
  333. const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, options);
  334. super(user, container, delegate, columns, renderers, Object.assign(Object.assign(Object.assign({ keyboardSupport: false }, computeStyles(themeService.getColorTheme(), defaultListStyles)), workbenchListOptions), { horizontalScrolling }));
  335. this.disposables.add(workbenchListOptionsDisposable);
  336. this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
  337. this.themeService = themeService;
  338. this.listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
  339. this.listSupportsMultiSelect.set(options.multipleSelectionSupport !== false);
  340. const listSelectionNavigation = WorkbenchListSelectionNavigation.bindTo(this.contextKeyService);
  341. listSelectionNavigation.set(Boolean(options.selectionNavigation));
  342. this.listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
  343. this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
  344. this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
  345. this.horizontalScrolling = options.horizontalScrolling;
  346. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  347. this.disposables.add(this.contextKeyService);
  348. this.disposables.add(listService.register(this));
  349. if (options.overrideStyles) {
  350. this.updateStyles(options.overrideStyles);
  351. }
  352. this.disposables.add(this.onDidChangeSelection(() => {
  353. const selection = this.getSelection();
  354. const focus = this.getFocus();
  355. this.contextKeyService.bufferChangeEvents(() => {
  356. this.listHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  357. this.listMultiSelection.set(selection.length > 1);
  358. this.listDoubleSelection.set(selection.length === 2);
  359. });
  360. }));
  361. this.disposables.add(this.onDidChangeFocus(() => {
  362. const selection = this.getSelection();
  363. const focus = this.getFocus();
  364. this.listHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  365. }));
  366. this.disposables.add(configurationService.onDidChangeConfiguration(e => {
  367. if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
  368. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  369. }
  370. let options = {};
  371. if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
  372. const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
  373. options = Object.assign(Object.assign({}, options), { horizontalScrolling });
  374. }
  375. if (e.affectsConfiguration(listSmoothScrolling)) {
  376. const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
  377. options = Object.assign(Object.assign({}, options), { smoothScrolling });
  378. }
  379. if (e.affectsConfiguration(mouseWheelScrollSensitivityKey)) {
  380. const mouseWheelScrollSensitivity = configurationService.getValue(mouseWheelScrollSensitivityKey);
  381. options = Object.assign(Object.assign({}, options), { mouseWheelScrollSensitivity });
  382. }
  383. if (e.affectsConfiguration(fastScrollSensitivityKey)) {
  384. const fastScrollSensitivity = configurationService.getValue(fastScrollSensitivityKey);
  385. options = Object.assign(Object.assign({}, options), { fastScrollSensitivity });
  386. }
  387. if (Object.keys(options).length > 0) {
  388. this.updateOptions(options);
  389. }
  390. }));
  391. this.navigator = new TableResourceNavigator(this, Object.assign({ configurationService }, options));
  392. this.disposables.add(this.navigator);
  393. }
  394. updateOptions(options) {
  395. super.updateOptions(options);
  396. if (options.overrideStyles) {
  397. this.updateStyles(options.overrideStyles);
  398. }
  399. if (options.multipleSelectionSupport !== undefined) {
  400. this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
  401. }
  402. }
  403. updateStyles(styles) {
  404. var _a;
  405. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  406. this._styler = attachListStyler(this, this.themeService, styles);
  407. }
  408. dispose() {
  409. var _a;
  410. (_a = this._styler) === null || _a === void 0 ? void 0 : _a.dispose();
  411. this.disposables.dispose();
  412. super.dispose();
  413. }
  414. };
  415. WorkbenchTable = __decorate([
  416. __param(6, IContextKeyService),
  417. __param(7, IListService),
  418. __param(8, IThemeService),
  419. __param(9, IConfigurationService),
  420. __param(10, IInstantiationService)
  421. ], WorkbenchTable);
  422. export { WorkbenchTable };
  423. class ResourceNavigator extends Disposable {
  424. constructor(widget, options) {
  425. var _a;
  426. super();
  427. this.widget = widget;
  428. this._onDidOpen = this._register(new Emitter());
  429. this.onDidOpen = this._onDidOpen.event;
  430. this._register(Event.filter(this.widget.onDidChangeSelection, e => e.browserEvent instanceof KeyboardEvent)(e => this.onSelectionFromKeyboard(e)));
  431. this._register(this.widget.onPointer((e) => this.onPointer(e.element, e.browserEvent)));
  432. this._register(this.widget.onMouseDblClick((e) => this.onMouseDblClick(e.element, e.browserEvent)));
  433. if (typeof (options === null || options === void 0 ? void 0 : options.openOnSingleClick) !== 'boolean' && (options === null || options === void 0 ? void 0 : options.configurationService)) {
  434. this.openOnSingleClick = (options === null || options === void 0 ? void 0 : options.configurationService.getValue(openModeSettingKey)) !== 'doubleClick';
  435. this._register(options === null || options === void 0 ? void 0 : options.configurationService.onDidChangeConfiguration(() => {
  436. this.openOnSingleClick = (options === null || options === void 0 ? void 0 : options.configurationService.getValue(openModeSettingKey)) !== 'doubleClick';
  437. }));
  438. }
  439. else {
  440. this.openOnSingleClick = (_a = options === null || options === void 0 ? void 0 : options.openOnSingleClick) !== null && _a !== void 0 ? _a : true;
  441. }
  442. }
  443. onSelectionFromKeyboard(event) {
  444. if (event.elements.length !== 1) {
  445. return;
  446. }
  447. const selectionKeyboardEvent = event.browserEvent;
  448. const preserveFocus = typeof selectionKeyboardEvent.preserveFocus === 'boolean' ? selectionKeyboardEvent.preserveFocus : true;
  449. const pinned = typeof selectionKeyboardEvent.pinned === 'boolean' ? selectionKeyboardEvent.pinned : !preserveFocus;
  450. const sideBySide = false;
  451. this._open(this.getSelectedElement(), preserveFocus, pinned, sideBySide, event.browserEvent);
  452. }
  453. onPointer(element, browserEvent) {
  454. if (!this.openOnSingleClick) {
  455. return;
  456. }
  457. const isDoubleClick = browserEvent.detail === 2;
  458. if (isDoubleClick) {
  459. return;
  460. }
  461. const isMiddleClick = browserEvent.button === 1;
  462. const preserveFocus = true;
  463. const pinned = isMiddleClick;
  464. const sideBySide = browserEvent.ctrlKey || browserEvent.metaKey || browserEvent.altKey;
  465. this._open(element, preserveFocus, pinned, sideBySide, browserEvent);
  466. }
  467. onMouseDblClick(element, browserEvent) {
  468. if (!browserEvent) {
  469. return;
  470. }
  471. // copied from AbstractTree
  472. const target = browserEvent.target;
  473. const onTwistie = target.classList.contains('monaco-tl-twistie')
  474. || (target.classList.contains('monaco-icon-label') && target.classList.contains('folder-icon') && browserEvent.offsetX < 16);
  475. if (onTwistie) {
  476. return;
  477. }
  478. const preserveFocus = false;
  479. const pinned = true;
  480. const sideBySide = (browserEvent.ctrlKey || browserEvent.metaKey || browserEvent.altKey);
  481. this._open(element, preserveFocus, pinned, sideBySide, browserEvent);
  482. }
  483. _open(element, preserveFocus, pinned, sideBySide, browserEvent) {
  484. if (!element) {
  485. return;
  486. }
  487. this._onDidOpen.fire({
  488. editorOptions: {
  489. preserveFocus,
  490. pinned,
  491. revealIfVisible: true
  492. },
  493. sideBySide,
  494. element,
  495. browserEvent
  496. });
  497. }
  498. }
  499. class ListResourceNavigator extends ResourceNavigator {
  500. constructor(widget, options) {
  501. super(widget, options);
  502. this.widget = widget;
  503. }
  504. getSelectedElement() {
  505. return this.widget.getSelectedElements()[0];
  506. }
  507. }
  508. class TableResourceNavigator extends ResourceNavigator {
  509. constructor(widget, options) {
  510. super(widget, options);
  511. }
  512. getSelectedElement() {
  513. return this.widget.getSelectedElements()[0];
  514. }
  515. }
  516. class TreeResourceNavigator extends ResourceNavigator {
  517. constructor(widget, options) {
  518. super(widget, options);
  519. }
  520. getSelectedElement() {
  521. var _a;
  522. return (_a = this.widget.getSelection()[0]) !== null && _a !== void 0 ? _a : undefined;
  523. }
  524. }
  525. function createKeyboardNavigationEventFilter(keybindingService) {
  526. let inChord = false;
  527. return event => {
  528. if (event.toKeybinding().isModifierKey()) {
  529. return false;
  530. }
  531. if (inChord) {
  532. inChord = false;
  533. return false;
  534. }
  535. const result = keybindingService.softDispatch(event, event.target);
  536. if (result === null || result === void 0 ? void 0 : result.enterChord) {
  537. inChord = true;
  538. return false;
  539. }
  540. inChord = false;
  541. return !result;
  542. };
  543. }
  544. let WorkbenchObjectTree = class WorkbenchObjectTree extends ObjectTree {
  545. constructor(user, container, delegate, renderers, options, instantiationService, contextKeyService, listService, themeService, configurationService) {
  546. const { options: treeOptions, getTypeNavigationMode, disposable } = instantiationService.invokeFunction(workbenchTreeDataPreamble, options);
  547. super(user, container, delegate, renderers, treeOptions);
  548. this.disposables.add(disposable);
  549. this.internals = new WorkbenchTreeInternals(this, options, getTypeNavigationMode, options.overrideStyles, contextKeyService, listService, themeService, configurationService);
  550. this.disposables.add(this.internals);
  551. }
  552. updateOptions(options) {
  553. super.updateOptions(options);
  554. this.internals.updateOptions(options);
  555. }
  556. };
  557. WorkbenchObjectTree = __decorate([
  558. __param(5, IInstantiationService),
  559. __param(6, IContextKeyService),
  560. __param(7, IListService),
  561. __param(8, IThemeService),
  562. __param(9, IConfigurationService)
  563. ], WorkbenchObjectTree);
  564. export { WorkbenchObjectTree };
  565. let WorkbenchCompressibleObjectTree = class WorkbenchCompressibleObjectTree extends CompressibleObjectTree {
  566. constructor(user, container, delegate, renderers, options, instantiationService, contextKeyService, listService, themeService, configurationService) {
  567. const { options: treeOptions, getTypeNavigationMode, disposable } = instantiationService.invokeFunction(workbenchTreeDataPreamble, options);
  568. super(user, container, delegate, renderers, treeOptions);
  569. this.disposables.add(disposable);
  570. this.internals = new WorkbenchTreeInternals(this, options, getTypeNavigationMode, options.overrideStyles, contextKeyService, listService, themeService, configurationService);
  571. this.disposables.add(this.internals);
  572. }
  573. updateOptions(options = {}) {
  574. super.updateOptions(options);
  575. if (options.overrideStyles) {
  576. this.internals.updateStyleOverrides(options.overrideStyles);
  577. }
  578. this.internals.updateOptions(options);
  579. }
  580. };
  581. WorkbenchCompressibleObjectTree = __decorate([
  582. __param(5, IInstantiationService),
  583. __param(6, IContextKeyService),
  584. __param(7, IListService),
  585. __param(8, IThemeService),
  586. __param(9, IConfigurationService)
  587. ], WorkbenchCompressibleObjectTree);
  588. export { WorkbenchCompressibleObjectTree };
  589. let WorkbenchDataTree = class WorkbenchDataTree extends DataTree {
  590. constructor(user, container, delegate, renderers, dataSource, options, instantiationService, contextKeyService, listService, themeService, configurationService) {
  591. const { options: treeOptions, getTypeNavigationMode, disposable } = instantiationService.invokeFunction(workbenchTreeDataPreamble, options);
  592. super(user, container, delegate, renderers, dataSource, treeOptions);
  593. this.disposables.add(disposable);
  594. this.internals = new WorkbenchTreeInternals(this, options, getTypeNavigationMode, options.overrideStyles, contextKeyService, listService, themeService, configurationService);
  595. this.disposables.add(this.internals);
  596. }
  597. updateOptions(options = {}) {
  598. super.updateOptions(options);
  599. if (options.overrideStyles) {
  600. this.internals.updateStyleOverrides(options.overrideStyles);
  601. }
  602. this.internals.updateOptions(options);
  603. }
  604. };
  605. WorkbenchDataTree = __decorate([
  606. __param(6, IInstantiationService),
  607. __param(7, IContextKeyService),
  608. __param(8, IListService),
  609. __param(9, IThemeService),
  610. __param(10, IConfigurationService)
  611. ], WorkbenchDataTree);
  612. export { WorkbenchDataTree };
  613. let WorkbenchAsyncDataTree = class WorkbenchAsyncDataTree extends AsyncDataTree {
  614. constructor(user, container, delegate, renderers, dataSource, options, instantiationService, contextKeyService, listService, themeService, configurationService) {
  615. const { options: treeOptions, getTypeNavigationMode, disposable } = instantiationService.invokeFunction(workbenchTreeDataPreamble, options);
  616. super(user, container, delegate, renderers, dataSource, treeOptions);
  617. this.disposables.add(disposable);
  618. this.internals = new WorkbenchTreeInternals(this, options, getTypeNavigationMode, options.overrideStyles, contextKeyService, listService, themeService, configurationService);
  619. this.disposables.add(this.internals);
  620. }
  621. get onDidOpen() { return this.internals.onDidOpen; }
  622. updateOptions(options = {}) {
  623. super.updateOptions(options);
  624. if (options.overrideStyles) {
  625. this.internals.updateStyleOverrides(options.overrideStyles);
  626. }
  627. this.internals.updateOptions(options);
  628. }
  629. };
  630. WorkbenchAsyncDataTree = __decorate([
  631. __param(6, IInstantiationService),
  632. __param(7, IContextKeyService),
  633. __param(8, IListService),
  634. __param(9, IThemeService),
  635. __param(10, IConfigurationService)
  636. ], WorkbenchAsyncDataTree);
  637. export { WorkbenchAsyncDataTree };
  638. let WorkbenchCompressibleAsyncDataTree = class WorkbenchCompressibleAsyncDataTree extends CompressibleAsyncDataTree {
  639. constructor(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, options, instantiationService, contextKeyService, listService, themeService, configurationService) {
  640. const { options: treeOptions, getTypeNavigationMode, disposable } = instantiationService.invokeFunction(workbenchTreeDataPreamble, options);
  641. super(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, treeOptions);
  642. this.disposables.add(disposable);
  643. this.internals = new WorkbenchTreeInternals(this, options, getTypeNavigationMode, options.overrideStyles, contextKeyService, listService, themeService, configurationService);
  644. this.disposables.add(this.internals);
  645. }
  646. updateOptions(options) {
  647. super.updateOptions(options);
  648. this.internals.updateOptions(options);
  649. }
  650. };
  651. WorkbenchCompressibleAsyncDataTree = __decorate([
  652. __param(7, IInstantiationService),
  653. __param(8, IContextKeyService),
  654. __param(9, IListService),
  655. __param(10, IThemeService),
  656. __param(11, IConfigurationService)
  657. ], WorkbenchCompressibleAsyncDataTree);
  658. export { WorkbenchCompressibleAsyncDataTree };
  659. function getDefaultTreeFindMode(configurationService) {
  660. const value = configurationService.getValue(defaultFindModeSettingKey);
  661. if (value === 'highlight') {
  662. return TreeFindMode.Highlight;
  663. }
  664. else if (value === 'filter') {
  665. return TreeFindMode.Filter;
  666. }
  667. const deprecatedValue = configurationService.getValue(keyboardNavigationSettingKey);
  668. if (deprecatedValue === 'simple' || deprecatedValue === 'highlight') {
  669. return TreeFindMode.Highlight;
  670. }
  671. else if (deprecatedValue === 'filter') {
  672. return TreeFindMode.Filter;
  673. }
  674. return undefined;
  675. }
  676. function workbenchTreeDataPreamble(accessor, options) {
  677. var _a;
  678. const configurationService = accessor.get(IConfigurationService);
  679. const contextViewService = accessor.get(IContextViewService);
  680. const contextKeyService = accessor.get(IContextKeyService);
  681. const instantiationService = accessor.get(IInstantiationService);
  682. const getTypeNavigationMode = () => {
  683. // give priority to the context key value to specify a value
  684. const modeString = contextKeyService.getContextKeyValue(WorkbenchListTypeNavigationModeKey);
  685. if (modeString === 'automatic') {
  686. return TypeNavigationMode.Automatic;
  687. }
  688. else if (modeString === 'trigger') {
  689. return TypeNavigationMode.Trigger;
  690. }
  691. // also check the deprecated context key to set the mode to 'trigger'
  692. const modeBoolean = contextKeyService.getContextKeyValue(WorkbenchListAutomaticKeyboardNavigationLegacyKey);
  693. if (modeBoolean === false) {
  694. return TypeNavigationMode.Trigger;
  695. }
  696. return undefined;
  697. };
  698. const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
  699. const [workbenchListOptions, disposable] = instantiationService.invokeFunction(toWorkbenchListOptions, options);
  700. const additionalScrollHeight = options.additionalScrollHeight;
  701. return {
  702. getTypeNavigationMode,
  703. disposable,
  704. options: Object.assign(Object.assign({
  705. // ...options, // TODO@Joao why is this not splatted here?
  706. keyboardSupport: false }, workbenchListOptions), { indent: typeof configurationService.getValue(treeIndentKey) === 'number' ? configurationService.getValue(treeIndentKey) : undefined, renderIndentGuides: configurationService.getValue(treeRenderIndentGuidesKey), smoothScrolling: Boolean(configurationService.getValue(listSmoothScrolling)), defaultFindMode: getDefaultTreeFindMode(configurationService), horizontalScrolling,
  707. additionalScrollHeight, hideTwistiesOfChildlessElements: options.hideTwistiesOfChildlessElements, expandOnlyOnTwistieClick: (_a = options.expandOnlyOnTwistieClick) !== null && _a !== void 0 ? _a : (configurationService.getValue(treeExpandMode) === 'doubleClick'), contextViewProvider: contextViewService })
  708. };
  709. }
  710. let WorkbenchTreeInternals = class WorkbenchTreeInternals {
  711. constructor(tree, options, getTypeNavigationMode, overrideStyles, contextKeyService, listService, themeService, configurationService) {
  712. var _a;
  713. this.tree = tree;
  714. this.themeService = themeService;
  715. this.disposables = [];
  716. this.contextKeyService = createScopedContextKeyService(contextKeyService, tree);
  717. this.listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
  718. this.listSupportsMultiSelect.set(options.multipleSelectionSupport !== false);
  719. const listSelectionNavigation = WorkbenchListSelectionNavigation.bindTo(this.contextKeyService);
  720. listSelectionNavigation.set(Boolean(options.selectionNavigation));
  721. this.listSupportFindWidget = WorkbenchListSupportsFind.bindTo(this.contextKeyService);
  722. this.listSupportFindWidget.set((_a = options.findWidgetEnabled) !== null && _a !== void 0 ? _a : true);
  723. this.hasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
  724. this.hasDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
  725. this.hasMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
  726. this.treeElementCanCollapse = WorkbenchTreeElementCanCollapse.bindTo(this.contextKeyService);
  727. this.treeElementHasParent = WorkbenchTreeElementHasParent.bindTo(this.contextKeyService);
  728. this.treeElementCanExpand = WorkbenchTreeElementCanExpand.bindTo(this.contextKeyService);
  729. this.treeElementHasChild = WorkbenchTreeElementHasChild.bindTo(this.contextKeyService);
  730. this.treeFindOpen = WorkbenchTreeFindOpen.bindTo(this.contextKeyService);
  731. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  732. this.updateStyleOverrides(overrideStyles);
  733. const updateCollapseContextKeys = () => {
  734. const focus = tree.getFocus()[0];
  735. if (!focus) {
  736. return;
  737. }
  738. const node = tree.getNode(focus);
  739. this.treeElementCanCollapse.set(node.collapsible && !node.collapsed);
  740. this.treeElementHasParent.set(!!tree.getParentElement(focus));
  741. this.treeElementCanExpand.set(node.collapsible && node.collapsed);
  742. this.treeElementHasChild.set(!!tree.getFirstElementChild(focus));
  743. };
  744. const interestingContextKeys = new Set();
  745. interestingContextKeys.add(WorkbenchListTypeNavigationModeKey);
  746. interestingContextKeys.add(WorkbenchListAutomaticKeyboardNavigationLegacyKey);
  747. this.disposables.push(this.contextKeyService, listService.register(tree), tree.onDidChangeSelection(() => {
  748. const selection = tree.getSelection();
  749. const focus = tree.getFocus();
  750. this.contextKeyService.bufferChangeEvents(() => {
  751. this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  752. this.hasMultiSelection.set(selection.length > 1);
  753. this.hasDoubleSelection.set(selection.length === 2);
  754. });
  755. }), tree.onDidChangeFocus(() => {
  756. const selection = tree.getSelection();
  757. const focus = tree.getFocus();
  758. this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  759. updateCollapseContextKeys();
  760. }), tree.onDidChangeCollapseState(updateCollapseContextKeys), tree.onDidChangeModel(updateCollapseContextKeys), tree.onDidChangeFindOpenState(enabled => this.treeFindOpen.set(enabled)), configurationService.onDidChangeConfiguration(e => {
  761. let newOptions = {};
  762. if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
  763. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  764. }
  765. if (e.affectsConfiguration(treeIndentKey)) {
  766. const indent = configurationService.getValue(treeIndentKey);
  767. newOptions = Object.assign(Object.assign({}, newOptions), { indent });
  768. }
  769. if (e.affectsConfiguration(treeRenderIndentGuidesKey)) {
  770. const renderIndentGuides = configurationService.getValue(treeRenderIndentGuidesKey);
  771. newOptions = Object.assign(Object.assign({}, newOptions), { renderIndentGuides });
  772. }
  773. if (e.affectsConfiguration(listSmoothScrolling)) {
  774. const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
  775. newOptions = Object.assign(Object.assign({}, newOptions), { smoothScrolling });
  776. }
  777. if (e.affectsConfiguration(defaultFindModeSettingKey) || e.affectsConfiguration(keyboardNavigationSettingKey)) {
  778. tree.updateOptions({ defaultFindMode: getDefaultTreeFindMode(configurationService) });
  779. }
  780. if (e.affectsConfiguration(horizontalScrollingKey) && options.horizontalScrolling === undefined) {
  781. const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
  782. newOptions = Object.assign(Object.assign({}, newOptions), { horizontalScrolling });
  783. }
  784. if (e.affectsConfiguration(treeExpandMode) && options.expandOnlyOnTwistieClick === undefined) {
  785. newOptions = Object.assign(Object.assign({}, newOptions), { expandOnlyOnTwistieClick: configurationService.getValue(treeExpandMode) === 'doubleClick' });
  786. }
  787. if (e.affectsConfiguration(mouseWheelScrollSensitivityKey)) {
  788. const mouseWheelScrollSensitivity = configurationService.getValue(mouseWheelScrollSensitivityKey);
  789. newOptions = Object.assign(Object.assign({}, newOptions), { mouseWheelScrollSensitivity });
  790. }
  791. if (e.affectsConfiguration(fastScrollSensitivityKey)) {
  792. const fastScrollSensitivity = configurationService.getValue(fastScrollSensitivityKey);
  793. newOptions = Object.assign(Object.assign({}, newOptions), { fastScrollSensitivity });
  794. }
  795. if (Object.keys(newOptions).length > 0) {
  796. tree.updateOptions(newOptions);
  797. }
  798. }), this.contextKeyService.onDidChangeContext(e => {
  799. if (e.affectsSome(interestingContextKeys)) {
  800. tree.updateOptions({ typeNavigationMode: getTypeNavigationMode() });
  801. }
  802. }));
  803. this.navigator = new TreeResourceNavigator(tree, Object.assign({ configurationService }, options));
  804. this.disposables.push(this.navigator);
  805. }
  806. get onDidOpen() { return this.navigator.onDidOpen; }
  807. updateOptions(options) {
  808. if (options.multipleSelectionSupport !== undefined) {
  809. this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
  810. }
  811. }
  812. updateStyleOverrides(overrideStyles) {
  813. dispose(this.styler);
  814. this.styler = overrideStyles ? attachListStyler(this.tree, this.themeService, overrideStyles) : Disposable.None;
  815. }
  816. dispose() {
  817. this.disposables = dispose(this.disposables);
  818. dispose(this.styler);
  819. this.styler = undefined;
  820. }
  821. };
  822. WorkbenchTreeInternals = __decorate([
  823. __param(4, IContextKeyService),
  824. __param(5, IListService),
  825. __param(6, IThemeService),
  826. __param(7, IConfigurationService)
  827. ], WorkbenchTreeInternals);
  828. const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration);
  829. configurationRegistry.registerConfiguration({
  830. id: 'workbench',
  831. order: 7,
  832. title: localize('workbenchConfigurationTitle', "Workbench"),
  833. type: 'object',
  834. properties: {
  835. [multiSelectModifierSettingKey]: {
  836. type: 'string',
  837. enum: ['ctrlCmd', 'alt'],
  838. markdownEnumDescriptions: [
  839. localize('multiSelectModifier.ctrlCmd', "Maps to `Control` on Windows and Linux and to `Command` on macOS."),
  840. localize('multiSelectModifier.alt', "Maps to `Alt` on Windows and Linux and to `Option` on macOS.")
  841. ],
  842. default: 'ctrlCmd',
  843. description: localize({
  844. key: 'multiSelectModifier',
  845. comment: [
  846. '- `ctrlCmd` refers to a value the setting can take and should not be localized.',
  847. '- `Control` and `Command` refer to the modifier keys Ctrl or Cmd on the keyboard and can be localized.'
  848. ]
  849. }, "The modifier to be used to add an item in trees and lists to a multi-selection with the mouse (for example in the explorer, open editors and scm view). The 'Open to Side' mouse gestures - if supported - will adapt such that they do not conflict with the multiselect modifier.")
  850. },
  851. [openModeSettingKey]: {
  852. type: 'string',
  853. enum: ['singleClick', 'doubleClick'],
  854. default: 'singleClick',
  855. description: localize({
  856. key: 'openModeModifier',
  857. comment: ['`singleClick` and `doubleClick` refers to a value the setting can take and should not be localized.']
  858. }, "Controls how to open items in trees and lists using the mouse (if supported). Note that some trees and lists might choose to ignore this setting if it is not applicable.")
  859. },
  860. [horizontalScrollingKey]: {
  861. type: 'boolean',
  862. default: false,
  863. description: localize('horizontalScrolling setting', "Controls whether lists and trees support horizontal scrolling in the workbench. Warning: turning on this setting has a performance implication.")
  864. },
  865. [treeIndentKey]: {
  866. type: 'number',
  867. default: 8,
  868. minimum: 4,
  869. maximum: 40,
  870. description: localize('tree indent setting', "Controls tree indentation in pixels.")
  871. },
  872. [treeRenderIndentGuidesKey]: {
  873. type: 'string',
  874. enum: ['none', 'onHover', 'always'],
  875. default: 'onHover',
  876. description: localize('render tree indent guides', "Controls whether the tree should render indent guides.")
  877. },
  878. [listSmoothScrolling]: {
  879. type: 'boolean',
  880. default: false,
  881. description: localize('list smoothScrolling setting', "Controls whether lists and trees have smooth scrolling."),
  882. },
  883. [mouseWheelScrollSensitivityKey]: {
  884. type: 'number',
  885. default: 1,
  886. markdownDescription: localize('Mouse Wheel Scroll Sensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.")
  887. },
  888. [fastScrollSensitivityKey]: {
  889. type: 'number',
  890. default: 5,
  891. description: localize('Fast Scroll Sensitivity', "Scrolling speed multiplier when pressing `Alt`.")
  892. },
  893. [defaultFindModeSettingKey]: {
  894. type: 'string',
  895. enum: ['highlight', 'filter'],
  896. enumDescriptions: [
  897. localize('defaultFindModeSettingKey.highlight', "Highlight elements when searching. Further up and down navigation will traverse only the highlighted elements."),
  898. localize('defaultFindModeSettingKey.filter', "Filter elements when searching.")
  899. ],
  900. default: 'highlight',
  901. description: localize('defaultFindModeSettingKey', "Controls the default find mode for lists and trees in the workbench.")
  902. },
  903. [keyboardNavigationSettingKey]: {
  904. type: 'string',
  905. enum: ['simple', 'highlight', 'filter'],
  906. enumDescriptions: [
  907. localize('keyboardNavigationSettingKey.simple', "Simple keyboard navigation focuses elements which match the keyboard input. Matching is done only on prefixes."),
  908. localize('keyboardNavigationSettingKey.highlight', "Highlight keyboard navigation highlights elements which match the keyboard input. Further up and down navigation will traverse only the highlighted elements."),
  909. localize('keyboardNavigationSettingKey.filter', "Filter keyboard navigation will filter out and hide all the elements which do not match the keyboard input.")
  910. ],
  911. default: 'highlight',
  912. description: localize('keyboardNavigationSettingKey', "Controls the keyboard navigation style for lists and trees in the workbench. Can be simple, highlight and filter."),
  913. deprecated: true,
  914. deprecationMessage: localize('keyboardNavigationSettingKeyDeprecated', "Please use 'workbench.list.defaultFindMode' instead.")
  915. },
  916. [treeExpandMode]: {
  917. type: 'string',
  918. enum: ['singleClick', 'doubleClick'],
  919. default: 'singleClick',
  920. description: localize('expand mode', "Controls how tree folders are expanded when clicking the folder names. Note that some trees and lists might choose to ignore this setting if it is not applicable."),
  921. }
  922. }
  923. });