提交 df93ca01 编写于 作者: J Joao Moreno

use keybindingService.mightProducePrintableCharacter in workbench lists/trees

上级 bb2da0c7
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { GestureEvent } from 'vs/base/browser/touch';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
export interface IListVirtualDelegate<T> {
getHeight(element: T): number;
......@@ -56,4 +57,5 @@ export interface IIdentityProvider<T> {
export interface ITypeLabelProvider<T> {
getTypeLabel(element: T): { toString(): string; };
mightProducePrintableCharacter?(event: IKeyboardEvent): boolean;
}
\ No newline at end of file
......@@ -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<T> 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<T> 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;
......
......@@ -161,13 +161,22 @@ class WorkbenchOpenController implements IOpenController {
}
}
function handleListControllers<T>(options: IListOptions<T>, configurationService: IConfigurationService): IListOptions<T> {
function toWorkbenchListOptions<T>(options: IListOptions<T>, configurationService: IConfigurationService, keybindingService: IKeybindingService): IListOptions<T> {
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<T> extends List<T> {
@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<T> extends List<T> {
selectOnMouseDown: true,
styleController: new DefaultStyleController(getSharedListStyleSheet()),
...computeStyles(themeService.getTheme(), defaultListStyles),
...handleListControllers(options, configurationService)
...toWorkbenchListOptions(options, configurationService, keybindingService)
} as IListOptions<T>
);
......@@ -294,7 +304,8 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
@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<T> extends PagedList<T> {
selectOnMouseDown: true,
styleController: new DefaultStyleController(getSharedListStyleSheet()),
...computeStyles(themeService.getTheme(), defaultListStyles),
...handleListControllers(options, configurationService)
...toWorkbenchListOptions(options, configurationService, keybindingService)
} as IListOptions<T>
);
......@@ -885,14 +896,15 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, 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<T extends NonNullable<any>, 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);
......
......@@ -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(() => {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
......@@ -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));
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册