mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 10:27:46 +00:00
parent
646345fba6
commit
ca8c68b380
|
@ -424,6 +424,7 @@ class TypeNavigationController<T> implements IDisposable {
|
|||
private list: List<T>,
|
||||
private view: ListView<T>,
|
||||
private keyboardNavigationLabelProvider: IKeyboardNavigationLabelProvider<T>,
|
||||
private keyboardNavigationEventFilter: IKeyboardNavigationEventFilter,
|
||||
private delegate: IKeyboardNavigationDelegate
|
||||
) {
|
||||
this.updateOptions(list.options);
|
||||
|
@ -448,12 +449,15 @@ class TypeNavigationController<T> implements IDisposable {
|
|||
return;
|
||||
}
|
||||
|
||||
let typing = false;
|
||||
|
||||
const onChar = this.enabledDisposables.add(Event.chain(this.enabledDisposables.add(new DomEmitter(this.view.domNode, 'keydown')).event))
|
||||
.filter(e => !isInputElement(e.target as HTMLElement))
|
||||
.filter(() => this.mode === TypeNavigationMode.Automatic || this.triggered)
|
||||
.map(event => new StandardKeyboardEvent(event))
|
||||
.filter(e => typing || this.keyboardNavigationEventFilter(e))
|
||||
.filter(e => this.delegate.mightProducePrintableCharacter(e))
|
||||
.forEach(e => { e.preventDefault(); e.stopPropagation(); })
|
||||
.forEach(stopEvent)
|
||||
.map(event => event.browserEvent.key)
|
||||
.event;
|
||||
|
||||
|
@ -463,6 +467,9 @@ class TypeNavigationController<T> implements IDisposable {
|
|||
onInput(this.onInput, this, this.enabledDisposables);
|
||||
onClear(this.onClear, this, this.enabledDisposables);
|
||||
|
||||
onChar(() => typing = true, undefined, this.enabledDisposables);
|
||||
onClear(() => typing = false, undefined, this.enabledDisposables);
|
||||
|
||||
this.enabled = true;
|
||||
this.triggered = false;
|
||||
}
|
||||
|
@ -919,6 +926,10 @@ export class DefaultStyleController implements IStyleController {
|
|||
}
|
||||
}
|
||||
|
||||
export interface IKeyboardNavigationEventFilter {
|
||||
(e: StandardKeyboardEvent): boolean;
|
||||
}
|
||||
|
||||
export interface IListOptionsUpdate extends IListViewOptionsUpdate {
|
||||
readonly typeNavigationEnabled?: boolean;
|
||||
readonly typeNavigationMode?: TypeNavigationMode;
|
||||
|
@ -934,6 +945,7 @@ export interface IListOptions<T> extends IListOptionsUpdate {
|
|||
readonly multipleSelectionController?: IMultipleSelectionController<T>;
|
||||
readonly styleController?: (suffix: string) => IStyleController;
|
||||
readonly accessibilityProvider?: IListAccessibilityProvider<T>;
|
||||
readonly keyboardNavigationEventFilter?: IKeyboardNavigationEventFilter;
|
||||
|
||||
// list view options
|
||||
readonly useShadows?: boolean;
|
||||
|
@ -1373,7 +1385,7 @@ export class List<T> implements ISpliceable<T>, IThemable, IDisposable {
|
|||
|
||||
if (_options.keyboardNavigationLabelProvider) {
|
||||
const delegate = _options.keyboardNavigationDelegate || DefaultKeyboardNavigationDelegate;
|
||||
this.typeNavigationController = new TypeNavigationController(this, this.view, _options.keyboardNavigationLabelProvider, delegate);
|
||||
this.typeNavigationController = new TypeNavigationController(this, this.view, _options.keyboardNavigationLabelProvider, _options.keyboardNavigationEventFilter ?? (() => true), delegate);
|
||||
this.disposables.add(this.typeNavigationController);
|
||||
}
|
||||
|
||||
|
|
|
@ -1003,10 +1003,6 @@ function asTreeContextMenuEvent<T>(event: IListContextMenuEvent<ITreeNode<T, any
|
|||
};
|
||||
}
|
||||
|
||||
export interface IKeyboardNavigationEventFilter {
|
||||
(e: StandardKeyboardEvent): boolean;
|
||||
}
|
||||
|
||||
export interface IAbstractTreeOptionsUpdate extends ITreeRendererOptions {
|
||||
readonly multipleSelectionSupport?: boolean;
|
||||
readonly typeNavigationEnabled?: boolean;
|
||||
|
@ -1025,7 +1021,6 @@ export interface IAbstractTreeOptions<T, TFilterData = void> extends IAbstractTr
|
|||
readonly collapseByDefault?: boolean; // defaults to false
|
||||
readonly filter?: ITreeFilter<T, TFilterData>;
|
||||
readonly dnd?: ITreeDragAndDrop<T>;
|
||||
readonly keyboardNavigationEventFilter?: IKeyboardNavigationEventFilter;
|
||||
readonly additionalScrollHeight?: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import { createStyleSheet } from 'vs/base/browser/dom';
|
|||
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { IListMouseEvent, IListRenderer, IListTouchEvent, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
|
||||
import { IPagedListOptions, IPagedRenderer, PagedList } from 'vs/base/browser/ui/list/listPaging';
|
||||
import { DefaultStyleController, IListAccessibilityProvider, IListOptions, IListOptionsUpdate, IMultipleSelectionController, isSelectionRangeChangeEvent, isSelectionSingleChangeEvent, List, TypeNavigationMode } from 'vs/base/browser/ui/list/listWidget';
|
||||
import { DefaultStyleController, IKeyboardNavigationEventFilter, IListAccessibilityProvider, IListOptions, IListOptionsUpdate, IMultipleSelectionController, isSelectionRangeChangeEvent, isSelectionSingleChangeEvent, List, TypeNavigationMode } from 'vs/base/browser/ui/list/listWidget';
|
||||
import { ITableColumn, ITableRenderer, ITableVirtualDelegate } from 'vs/base/browser/ui/table/table';
|
||||
import { ITableOptions, ITableOptionsUpdate, Table } from 'vs/base/browser/ui/table/tableWidget';
|
||||
import { TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, IKeyboardNavigationEventFilter, RenderIndentGuides } from 'vs/base/browser/ui/tree/abstractTree';
|
||||
import { TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, RenderIndentGuides } from 'vs/base/browser/ui/tree/abstractTree';
|
||||
import { AsyncDataTree, CompressibleAsyncDataTree, IAsyncDataTreeOptions, IAsyncDataTreeOptionsUpdate, ICompressibleAsyncDataTreeOptions, ICompressibleAsyncDataTreeOptionsUpdate, ITreeCompressionDelegate } from 'vs/base/browser/ui/tree/asyncDataTree';
|
||||
import { DataTree, IDataTreeOptions } from 'vs/base/browser/ui/tree/dataTree';
|
||||
import { CompressibleObjectTree, ICompressibleObjectTreeOptions, ICompressibleObjectTreeOptionsUpdate, ICompressibleTreeRenderer, IObjectTreeOptions, ObjectTree } from 'vs/base/browser/ui/tree/objectTree';
|
||||
|
@ -187,7 +187,14 @@ class MultipleSelectionController<T> extends Disposable implements IMultipleSele
|
|||
}
|
||||
}
|
||||
|
||||
function toWorkbenchListOptions<T>(options: IListOptions<T>, configurationService: IConfigurationService, keybindingService: IKeybindingService): [IListOptions<T>, IDisposable] {
|
||||
function toWorkbenchListOptions<T>(
|
||||
accessor: ServicesAccessor,
|
||||
container: HTMLElement,
|
||||
options: IListOptions<T>,
|
||||
): [IListOptions<T>, IDisposable] {
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
const keybindingService = accessor.get(IKeybindingService);
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
const result: IListOptions<T> = {
|
||||
...options,
|
||||
|
@ -195,7 +202,8 @@ function toWorkbenchListOptions<T>(options: IListOptions<T>, configurationServic
|
|||
smoothScrolling: Boolean(configurationService.getValue(listSmoothScrolling)),
|
||||
mouseWheelScrollSensitivity: configurationService.getValue<number>(mouseWheelScrollSensitivityKey),
|
||||
fastScrollSensitivity: configurationService.getValue<number>(fastScrollSensitivityKey),
|
||||
multipleSelectionController: options.multipleSelectionController ?? disposables.add(new MultipleSelectionController(configurationService))
|
||||
multipleSelectionController: options.multipleSelectionController ?? disposables.add(new MultipleSelectionController(configurationService)),
|
||||
keyboardNavigationEventFilter: createKeyboardNavigationEventFilter(container, keybindingService),
|
||||
};
|
||||
|
||||
return [result, disposables];
|
||||
|
@ -233,10 +241,10 @@ export class WorkbenchList<T> extends List<T> {
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, container, options);
|
||||
|
||||
super(user, container, delegate, renderers,
|
||||
{
|
||||
|
@ -373,10 +381,10 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, container, options);
|
||||
super(user, container, delegate, renderers,
|
||||
{
|
||||
keyboardSupport: false,
|
||||
|
@ -506,10 +514,10 @@ export class WorkbenchTable<TRow> extends Table<TRow> {
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
|
||||
const [workbenchListOptions, workbenchListOptionsDisposable] = instantiationService.invokeFunction(toWorkbenchListOptions, container, options);
|
||||
|
||||
super(user, container, delegate, columns, renderers,
|
||||
{
|
||||
|
@ -819,13 +827,13 @@ function createKeyboardNavigationEventFilter(container: HTMLElement, keybindingS
|
|||
|
||||
const result = keybindingService.softDispatch(event, container);
|
||||
|
||||
if (result && result.enterChord) {
|
||||
if (result?.enterChord) {
|
||||
inChord = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inChord = false;
|
||||
return true;
|
||||
return !result;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1076,6 +1084,7 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
|
|||
const keybindingService = accessor.get(IKeybindingService);
|
||||
const contextViewService = accessor.get(IContextViewService);
|
||||
const contextKeyService = accessor.get(IContextKeyService);
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
|
||||
const getTypeNavigationMode = () => {
|
||||
// give priority to the context key value to specify a value
|
||||
|
@ -1098,7 +1107,7 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
|
|||
};
|
||||
|
||||
const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
|
||||
const [workbenchListOptions, disposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
|
||||
const [workbenchListOptions, disposable] = instantiationService.invokeFunction(toWorkbenchListOptions, container, options);
|
||||
const additionalScrollHeight = options.additionalScrollHeight;
|
||||
|
||||
return {
|
||||
|
|
|
@ -310,8 +310,8 @@ export class NotebookTextDiffList extends WorkbenchList<DiffElementViewModelBase
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService) {
|
||||
super(listUser, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService);
|
||||
@IInstantiationService instantiationService: IInstantiationService) {
|
||||
super(listUser, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, instantiationService);
|
||||
}
|
||||
|
||||
protected override createMouseController(options: IListOptions<DiffElementViewModelBase>): MouseController<DiffElementViewModelBase> {
|
||||
|
|
|
@ -16,7 +16,6 @@ import { TrackedRangeStickiness } from 'vs/editor/common/model';
|
|||
import { PrefixSumComputer } from 'vs/editor/common/model/prefixSumComputer';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IListService, IWorkbenchListOptions, WorkbenchList } from 'vs/platform/list/browser/listService';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { CursorAtBoundary, ICellViewModel, CellEditState, CellFocusMode, ICellOutputViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
|
@ -30,6 +29,7 @@ import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/vie
|
|||
import { BaseCellRenderTemplate, INotebookCellList } from 'vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon';
|
||||
import { FastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const enum CellRevealType {
|
||||
Line,
|
||||
|
@ -157,9 +157,9 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super(listUser, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService);
|
||||
super(listUser, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, instantiationService);
|
||||
NOTEBOOK_CELL_LIST_FOCUSED.bindTo(this.contextKeyService).set(true);
|
||||
this._viewContext = viewContext;
|
||||
this._previousFocusedElements = this.getFocusedElements();
|
||||
|
|
|
@ -54,6 +54,8 @@ import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServic
|
|||
import { ResourceMap } from 'vs/base/common/map';
|
||||
import { TestClipboardService } from 'vs/platform/clipboard/test/common/testClipboardService';
|
||||
import { IWorkingCopySaveEvent } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
|
||||
export class TestCell extends NotebookCellTextModel {
|
||||
constructor(
|
||||
|
@ -173,6 +175,7 @@ export function setupInstantiationService(disposables = new DisposableStore()) {
|
|||
instantiationService.stub(IStorageService, new TestStorageService());
|
||||
instantiationService.stub(IWorkspaceTrustRequestService, new TestWorkspaceTrustRequestService(true));
|
||||
instantiationService.stub(INotebookExecutionStateService, new TestNotebookExecutionStateService());
|
||||
instantiationService.stub(IKeybindingService, new MockKeybindingService());
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
|
|||
@IListService listService: IListService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@ITerminalService private readonly _terminalService: ITerminalService,
|
||||
@ITerminalGroupService private readonly _terminalGroupService: ITerminalGroupService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
|
@ -103,7 +102,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
|
|||
listService,
|
||||
themeService,
|
||||
_configurationService,
|
||||
keybindingService,
|
||||
instantiationService,
|
||||
);
|
||||
|
||||
const instanceDisposables: IDisposable[] = [
|
||||
|
|
Loading…
Reference in a new issue