mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 3c6f6af7347d38e87bc6406024e8dcf9e9bce229 (#8962)
* Merge from vscode 3c6f6af7347d38e87bc6406024e8dcf9e9bce229 * skip failing tests * update mac build image
This commit is contained in:
committed by
Karl Burtram
parent
0eaee18dc4
commit
fefe1454de
@@ -30,7 +30,7 @@ import { ITreeEvent, ITreeRenderer, IAsyncDataSource, IDataSource, ITreeMouseEve
|
||||
import { AsyncDataTree, IAsyncDataTreeOptions, CompressibleAsyncDataTree, ITreeCompressionDelegate, ICompressibleAsyncDataTreeOptions } from 'vs/base/browser/ui/tree/asyncDataTree';
|
||||
import { DataTree, IDataTreeOptions } from 'vs/base/browser/ui/tree/dataTree';
|
||||
import { IKeyboardNavigationEventFilter, IAbstractTreeOptions, RenderIndentGuides } from 'vs/base/browser/ui/tree/abstractTree';
|
||||
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
export type ListWidget = List<any> | PagedList<any> | ITree | ObjectTree<any, any> | DataTree<any, any, any> | AsyncDataTree<any, any, any>;
|
||||
|
||||
@@ -58,18 +58,23 @@ export class ListService implements IListService {
|
||||
private disposables = new DisposableStore();
|
||||
private lists: IRegisteredList[] = [];
|
||||
private _lastFocusedWidget: ListWidget | undefined = undefined;
|
||||
private _hasCreatedStyleController: boolean = false;
|
||||
|
||||
get lastFocusedList(): ListWidget | undefined {
|
||||
return this._lastFocusedWidget;
|
||||
}
|
||||
|
||||
constructor(@IThemeService themeService: IThemeService) {
|
||||
// create a shared default tree style sheet for performance reasons
|
||||
const styleController = new DefaultStyleController(createStyleSheet(), '');
|
||||
this.disposables.add(attachListStyler(styleController, themeService));
|
||||
constructor(@IThemeService private readonly _themeService: IThemeService) {
|
||||
}
|
||||
|
||||
register(widget: ListWidget, extraContextKeys?: (IContextKey<boolean>)[]): IDisposable {
|
||||
if (!this._hasCreatedStyleController) {
|
||||
this._hasCreatedStyleController = true;
|
||||
// create a shared default tree style sheet for performance reasons
|
||||
const styleController = new DefaultStyleController(createStyleSheet(), '');
|
||||
this.disposables.add(attachListStyler(styleController, this._themeService));
|
||||
}
|
||||
|
||||
if (this.lists.some(l => l.widget === widget)) {
|
||||
throw new Error('Cannot register the same widget multiple times');
|
||||
}
|
||||
@@ -580,82 +585,6 @@ export interface IResourceResultsNavigationOptions {
|
||||
openOnFocus: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export class TreeResourceNavigator extends Disposable {
|
||||
|
||||
private readonly _openResource = new Emitter<IOpenResourceOptions>();
|
||||
readonly openResource: Event<IOpenResourceOptions> = this._openResource.event;
|
||||
|
||||
constructor(private tree: WorkbenchTree, private options?: IResourceResultsNavigationOptions) {
|
||||
super();
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
if (this.options && this.options.openOnFocus) {
|
||||
this._register(this.tree.onDidChangeFocus(e => this.onFocus(e)));
|
||||
}
|
||||
|
||||
this._register(this.tree.onDidChangeSelection(e => this.onSelection(e)));
|
||||
}
|
||||
|
||||
private onFocus({ payload }: any): void {
|
||||
const element = this.tree.getFocus();
|
||||
this.tree.setSelection([element], { fromFocus: true });
|
||||
|
||||
const originalEvent: KeyboardEvent | MouseEvent = payload && payload.originalEvent;
|
||||
const isMouseEvent = payload && payload.origin === 'mouse';
|
||||
const isDoubleClick = isMouseEvent && originalEvent && originalEvent.detail === 2;
|
||||
|
||||
const preventOpen = payload && payload.preventOpenOnFocus;
|
||||
if (!preventOpen && (!isMouseEvent || this.tree.openOnSingleClick || isDoubleClick)) {
|
||||
this._openResource.fire({
|
||||
editorOptions: {
|
||||
preserveFocus: true,
|
||||
pinned: false,
|
||||
revealIfVisible: true
|
||||
},
|
||||
sideBySide: false,
|
||||
element,
|
||||
payload
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private onSelection({ payload }: any): void {
|
||||
if (payload && payload.fromFocus) {
|
||||
return;
|
||||
}
|
||||
|
||||
const originalEvent: KeyboardEvent | MouseEvent = payload && payload.originalEvent;
|
||||
const isMouseEvent = payload && payload.origin === 'mouse';
|
||||
const isDoubleClick = isMouseEvent && originalEvent && originalEvent.detail === 2;
|
||||
|
||||
if (!isMouseEvent || this.tree.openOnSingleClick || isDoubleClick) {
|
||||
if (isDoubleClick && originalEvent) {
|
||||
originalEvent.preventDefault(); // focus moves to editor, we need to prevent default
|
||||
}
|
||||
|
||||
const isFromKeyboard = payload && payload.origin === 'keyboard';
|
||||
const sideBySide = (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey || originalEvent.altKey));
|
||||
const preserveFocus = !((isFromKeyboard && (!payload || !payload.preserveFocus)) || isDoubleClick || (payload && payload.focusEditor));
|
||||
this._openResource.fire({
|
||||
editorOptions: {
|
||||
preserveFocus,
|
||||
pinned: isDoubleClick,
|
||||
revealIfVisible: true
|
||||
},
|
||||
sideBySide,
|
||||
element: this.tree.getSelection()[0],
|
||||
payload
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOpenEvent<T> {
|
||||
editorOptions: IEditorOptions;
|
||||
sideBySide: boolean;
|
||||
@@ -663,9 +592,9 @@ export interface IOpenEvent<T> {
|
||||
browserEvent?: UIEvent;
|
||||
}
|
||||
|
||||
export interface IResourceResultsNavigationOptions2 {
|
||||
openOnFocus?: boolean;
|
||||
openOnSelection?: boolean;
|
||||
export interface ITreeResourceNavigatorOptions {
|
||||
readonly openOnFocus?: boolean;
|
||||
readonly openOnSelection?: boolean;
|
||||
}
|
||||
|
||||
export interface SelectionKeyboardEvent extends KeyboardEvent {
|
||||
@@ -679,16 +608,16 @@ export function getSelectionKeyboardEvent(typeArg = 'keydown', preserveFocus?: b
|
||||
return e;
|
||||
}
|
||||
|
||||
export class TreeResourceNavigator2<T, TFilterData> extends Disposable {
|
||||
export class TreeResourceNavigator<T, TFilterData> extends Disposable {
|
||||
|
||||
private options: IResourceResultsNavigationOptions2;
|
||||
private options: ITreeResourceNavigatorOptions;
|
||||
|
||||
private readonly _onDidOpenResource = new Emitter<IOpenEvent<T | null>>();
|
||||
readonly onDidOpenResource: Event<IOpenEvent<T | null>> = this._onDidOpenResource.event;
|
||||
|
||||
constructor(
|
||||
private tree: WorkbenchObjectTree<T, TFilterData> | WorkbenchCompressibleObjectTree<T, TFilterData> | WorkbenchDataTree<any, T, TFilterData> | WorkbenchAsyncDataTree<any, T, TFilterData> | WorkbenchCompressibleAsyncDataTree<any, T, TFilterData>,
|
||||
options?: IResourceResultsNavigationOptions2
|
||||
options?: ITreeResourceNavigatorOptions
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -971,7 +900,7 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
|
||||
return automaticKeyboardNavigation;
|
||||
};
|
||||
|
||||
const accessibilityOn = accessibilityService.getAccessibilitySupport() === AccessibilitySupport.Enabled;
|
||||
const accessibilityOn = accessibilityService.isScreenReaderOptimized();
|
||||
const keyboardNavigation = accessibilityOn ? 'simple' : configurationService.getValue<string>(keyboardNavigationSettingKey);
|
||||
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : getHorizontalScrollingSetting(configurationService);
|
||||
const openOnSingleClick = useSingleClickToOpen(configurationService);
|
||||
@@ -1033,7 +962,7 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
|
||||
const interestingContextKeys = new Set();
|
||||
interestingContextKeys.add(WorkbenchListAutomaticKeyboardNavigationKey);
|
||||
const updateKeyboardNavigation = () => {
|
||||
const accessibilityOn = accessibilityService.getAccessibilitySupport() === AccessibilitySupport.Enabled;
|
||||
const accessibilityOn = accessibilityService.isScreenReaderOptimized();
|
||||
const keyboardNavigation = accessibilityOn ? 'simple' : configurationService.getValue<string>(keyboardNavigationSettingKey);
|
||||
tree.updateOptions({
|
||||
simpleKeyboardNavigation: keyboardNavigation === 'simple',
|
||||
@@ -1086,7 +1015,7 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
|
||||
tree.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
|
||||
}
|
||||
}),
|
||||
accessibilityService.onDidChangeAccessibilitySupport(() => updateKeyboardNavigation())
|
||||
accessibilityService.onDidChangeScreenReaderOptimized(() => updateKeyboardNavigation())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user