diff --git a/src/vs/base/browser/ui/list/list.ts b/src/vs/base/browser/ui/list/list.ts index b4f0cb2b278..5efc6001991 100644 --- a/src/vs/base/browser/ui/list/list.ts +++ b/src/vs/base/browser/ui/list/list.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { GestureEvent } from 'vs/base/browser/touch'; +import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; export interface IListVirtualDelegate { getHeight(element: T): number; @@ -56,4 +57,5 @@ export interface IIdentityProvider { export interface ITypeLabelProvider { getTypeLabel(element: T): { toString(): string; }; + mightProducePrintableCharacter?(event: IKeyboardEvent): boolean; } \ No newline at end of file diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index eefe466f6a8..bedf2db6aa7 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -13,7 +13,7 @@ import * as DOM from 'vs/base/browser/dom'; import * as platform from 'vs/base/common/platform'; import { Gesture } from 'vs/base/browser/touch'; import { KeyCode } from 'vs/base/common/keyCodes'; -import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; +import { StandardKeyboardEvent, IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { Event, Emitter, EventBufferer } from 'vs/base/common/event'; import { domEvent } from 'vs/base/browser/event'; import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent, IListMouseEvent, IListTouchEvent, IListGestureEvent, IIdentityProvider, ITypeLabelProvider } from './list'; @@ -330,6 +330,16 @@ enum TypeLabelControllerState { class TypeLabelController implements IDisposable { + private static mightProducePrintableCharacter(event: IKeyboardEvent): boolean { + if (event.ctrlKey || event.metaKey || event.altKey) { + return false; + } + + return (event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z) + || (event.keyCode >= KeyCode.KEY_0 && event.keyCode <= KeyCode.KEY_9) + || (event.keyCode >= KeyCode.US_SEMICOLON && event.keyCode <= KeyCode.US_QUOTE); + } + private state: TypeLabelControllerState = TypeLabelControllerState.Idle; private disposables: IDisposable[] = []; @@ -340,15 +350,7 @@ class TypeLabelController implements IDisposable { ) { const onChar = Event.chain(domEvent(view.domNode, 'keydown')) .map(event => new StandardKeyboardEvent(event)) - .filter(event => { - if (event.ctrlKey || event.metaKey || event.altKey) { - return false; - } - - return (event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z) - || (event.keyCode >= KeyCode.KEY_0 && event.keyCode <= KeyCode.KEY_9) - || (event.keyCode >= KeyCode.US_SEMICOLON && event.keyCode <= KeyCode.US_QUOTE); - }) + .filter(typeLabelProvider.mightProducePrintableCharacter ? e => typeLabelProvider.mightProducePrintableCharacter!(e) : e => TypeLabelController.mightProducePrintableCharacter(e)) .map(event => event.browserEvent.key) .event; diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index d947e106f4e..7be0619e16d 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -161,13 +161,22 @@ class WorkbenchOpenController implements IOpenController { } } -function handleListControllers(options: IListOptions, configurationService: IConfigurationService): IListOptions { +function toWorkbenchListOptions(options: IListOptions, configurationService: IConfigurationService, keybindingService: IKeybindingService): IListOptions { if (options.multipleSelectionSupport !== false && !options.multipleSelectionController) { options.multipleSelectionController = new MultipleSelectionController(configurationService); } options.openController = new WorkbenchOpenController(configurationService, options.openController); + if (options.typeLabelProvider) { + const tlp = options.typeLabelProvider; + + options.typeLabelProvider = { + getTypeLabel(e) { return tlp.getTypeLabel(e); }, + mightProducePrintableCharacter(e) { return keybindingService.mightProducePrintableCharacter(e); } + }; + } + return options; } @@ -219,7 +228,8 @@ export class WorkbenchList extends List { @IContextKeyService contextKeyService: IContextKeyService, @IListService listService: IListService, @IThemeService themeService: IThemeService, - @IConfigurationService private configurationService: IConfigurationService + @IConfigurationService private configurationService: IConfigurationService, + @IKeybindingService keybindingService: IKeybindingService ) { super(container, delegate, renderers, { @@ -227,7 +237,7 @@ export class WorkbenchList extends List { selectOnMouseDown: true, styleController: new DefaultStyleController(getSharedListStyleSheet()), ...computeStyles(themeService.getTheme(), defaultListStyles), - ...handleListControllers(options, configurationService) + ...toWorkbenchListOptions(options, configurationService, keybindingService) } as IListOptions ); @@ -294,7 +304,8 @@ export class WorkbenchPagedList extends PagedList { @IContextKeyService contextKeyService: IContextKeyService, @IListService listService: IListService, @IThemeService themeService: IThemeService, - @IConfigurationService private configurationService: IConfigurationService + @IConfigurationService private configurationService: IConfigurationService, + @IKeybindingService keybindingService: IKeybindingService ) { super(container, delegate, renderers, { @@ -302,7 +313,7 @@ export class WorkbenchPagedList extends PagedList { selectOnMouseDown: true, styleController: new DefaultStyleController(getSharedListStyleSheet()), ...computeStyles(themeService.getTheme(), defaultListStyles), - ...handleListControllers(options, configurationService) + ...toWorkbenchListOptions(options, configurationService, keybindingService) } as IListOptions ); @@ -885,14 +896,15 @@ export class WorkbenchObjectTree, TFilterData = void> @IContextKeyService contextKeyService: IContextKeyService, @IListService listService: IListService, @IThemeService themeService: IThemeService, - @IConfigurationService configurationService: IConfigurationService + @IConfigurationService configurationService: IConfigurationService, + @IKeybindingService keybindingService: IKeybindingService ) { super(container, delegate, renderers, { keyboardSupport: false, selectOnMouseDown: true, styleController: new DefaultStyleController(getSharedListStyleSheet()), ...computeStyles(themeService.getTheme(), defaultListStyles), - ...handleListControllers(options, configurationService) + ...toWorkbenchListOptions(options, configurationService, keybindingService) }); this.contextKeyService = createScopedContextKeyService(contextKeyService, this); @@ -948,14 +960,15 @@ export class WorkbenchAsyncDataTree, TFilterData = vo @IContextKeyService contextKeyService: IContextKeyService, @IListService listService: IListService, @IThemeService themeService: IThemeService, - @IConfigurationService configurationService: IConfigurationService + @IConfigurationService configurationService: IConfigurationService, + @IKeybindingService keybindingService: IKeybindingService ) { super(container, delegate, renderers, dataSource, { keyboardSupport: false, selectOnMouseDown: true, styleController: new DefaultStyleController(getSharedListStyleSheet()), ...computeStyles(themeService.getTheme(), defaultListStyles), - ...handleListControllers(options, configurationService) + ...toWorkbenchListOptions(options, configurationService, keybindingService) }); this.contextKeyService = createScopedContextKeyService(contextKeyService, this); diff --git a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts index c21e7f71b31..c504506c287 100644 --- a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts @@ -409,7 +409,7 @@ export class LoadedScriptsView extends ViewletPanel { accessibilityProvider: new LoadedSciptsAccessibilityProvider(), ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'loadedScriptsAriaLabel' }, "Debug Loaded Scripts"), }, - this.contextKeyService, this.listService, this.themeService, this.configurationService + this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService ); this.changeScheduler = new RunOnceScheduler(() => { diff --git a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts index 019651b3c98..48219c16817 100644 --- a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts @@ -125,7 +125,7 @@ export class CallStackView extends ViewletPanel { return element.getId(); } } - }, this.contextKeyService, this.listService, this.themeService, this.configurationService); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService); const callstackNavigator = new TreeResourceNavigator2(this.tree); this.disposables.push(callstackNavigator); diff --git a/src/vs/workbench/parts/debug/electron-browser/debugHover.ts b/src/vs/workbench/parts/debug/electron-browser/debugHover.ts index d28e326f9fa..9e250067c3a 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugHover.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugHover.ts @@ -31,6 +31,7 @@ import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/l import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { coalesce } from 'vs/base/common/arrays'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; const $ = dom.$; const MAX_TREE_HEIGHT = 324; @@ -61,7 +62,8 @@ export class DebugHoverWidget implements IContentWidget { @IThemeService private themeService: IThemeService, @IContextKeyService private contextKeyService: IContextKeyService, @IListService private listService: IListService, - @IConfigurationService private configurationService: IConfigurationService + @IConfigurationService private configurationService: IConfigurationService, + @IKeybindingService private keybindingService: IKeybindingService ) { this.toDispose = []; @@ -83,7 +85,7 @@ export class DebugHoverWidget implements IContentWidget { ariaLabel: nls.localize('treeAriaLabel', "Debug Hover"), accessibilityProvider: new DebugHoverAccessibilityProvider(), mouseSupport: false - }, this.contextKeyService, this.listService, this.themeService, this.configurationService); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService); this.valueContainer = $('.value'); this.valueContainer.tabIndex = 0; diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 3e4b66a7f59..3e846dc3813 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -67,6 +67,7 @@ import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/l import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; import { RunOnceScheduler } from 'vs/base/common/async'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; const $ = dom.$; @@ -122,7 +123,8 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati @IContextMenuService private contextMenuService: IContextMenuService, @IListService private listService: IListService, @IConfigurationService private configurationService: IConfigurationService, - @ITextResourcePropertiesService private textResourcePropertiesService: ITextResourcePropertiesService + @ITextResourcePropertiesService private textResourcePropertiesService: ITextResourcePropertiesService, + @IKeybindingService private keybindingService: IKeybindingService ) { super(REPL_ID, telemetryService, themeService, storageService); @@ -360,7 +362,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati accessibilityProvider: new ReplAccessibilityProvider(), identityProvider: { getId: element => element.getId() }, mouseSupport: false - }, this.contextKeyService, this.listService, this.themeService, this.configurationService); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService); this.toDispose.push(this.tree.onContextMenu(e => this.onContextMenu(e))); // Make sure to select the session if debugging is already active diff --git a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts index 62271136f01..22276dc13ca 100644 --- a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts @@ -80,7 +80,7 @@ export class VariablesView extends ViewletPanel { ariaLabel: nls.localize('variablesAriaTreeLabel', "Debug Variables"), accessibilityProvider: new VariablesAccessibilityProvider(), identityProvider: { getId: element => element.getId() } - }, this.contextKeyService, this.listService, this.themeService, this.configurationService); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService); CONTEXT_VARIABLES_FOCUSED.bindTo(this.contextKeyService.createScoped(treeContainer)); diff --git a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts index b02c2204b80..fb0c0ea3585 100644 --- a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts @@ -68,7 +68,7 @@ export class WatchExpressionsView extends ViewletPanel { ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'watchAriaTreeLabel' }, "Debug Watch Expressions"), accessibilityProvider: new WatchExpressionsAccessibilityProvider(), identityProvider: { getId: element => element.getId() } - }, this.contextKeyService, this.listService, this.themeService, this.configurationService); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService); this.tree.refresh(null);