mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Mark list event objects as readonly (#175722)
This marks the objects fired by list/tree events as readonly. This prevents one event from mistakenly effecting other events by modifying the event object
This commit is contained in:
parent
0393891daf
commit
6c771e3377
|
@ -24,40 +24,40 @@ export interface IListRenderer<T, TTemplateData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListEvent<T> {
|
export interface IListEvent<T> {
|
||||||
elements: T[];
|
readonly elements: readonly T[];
|
||||||
indexes: number[];
|
readonly indexes: readonly number[];
|
||||||
browserEvent?: UIEvent;
|
readonly browserEvent?: UIEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListMouseEvent<T> {
|
export interface IListMouseEvent<T> {
|
||||||
browserEvent: MouseEvent;
|
readonly browserEvent: MouseEvent;
|
||||||
element: T | undefined;
|
readonly element: T | undefined;
|
||||||
index: number | undefined;
|
readonly index: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListTouchEvent<T> {
|
export interface IListTouchEvent<T> {
|
||||||
browserEvent: TouchEvent;
|
readonly browserEvent: TouchEvent;
|
||||||
element: T | undefined;
|
readonly element: T | undefined;
|
||||||
index: number | undefined;
|
readonly index: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListGestureEvent<T> {
|
export interface IListGestureEvent<T> {
|
||||||
browserEvent: GestureEvent;
|
readonly browserEvent: GestureEvent;
|
||||||
element: T | undefined;
|
readonly element: T | undefined;
|
||||||
index: number | undefined;
|
readonly index: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListDragEvent<T> {
|
export interface IListDragEvent<T> {
|
||||||
browserEvent: DragEvent;
|
readonly browserEvent: DragEvent;
|
||||||
element: T | undefined;
|
readonly element: T | undefined;
|
||||||
index: number | undefined;
|
readonly index: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IListContextMenuEvent<T> {
|
export interface IListContextMenuEvent<T> {
|
||||||
browserEvent: UIEvent;
|
readonly browserEvent: UIEvent;
|
||||||
element: T | undefined;
|
readonly element: T | undefined;
|
||||||
index: number | undefined;
|
readonly index: number | undefined;
|
||||||
anchor: HTMLElement | { x: number; y: number };
|
readonly anchor: HTMLElement | { readonly x: number; readonly y: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IIdentityProvider<T> {
|
export interface IIdentityProvider<T> {
|
||||||
|
|
|
@ -134,8 +134,8 @@ export interface ITreeRenderer<T, TFilterData = void, TTemplateData = void> exte
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITreeEvent<T> {
|
export interface ITreeEvent<T> {
|
||||||
elements: T[];
|
readonly elements: readonly T[];
|
||||||
browserEvent?: UIEvent;
|
readonly browserEvent?: UIEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TreeMouseEventTarget {
|
export enum TreeMouseEventTarget {
|
||||||
|
@ -146,15 +146,15 @@ export enum TreeMouseEventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITreeMouseEvent<T> {
|
export interface ITreeMouseEvent<T> {
|
||||||
browserEvent: MouseEvent;
|
readonly browserEvent: MouseEvent;
|
||||||
element: T | null;
|
readonly element: T | null;
|
||||||
target: TreeMouseEventTarget;
|
readonly target: TreeMouseEventTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITreeContextMenuEvent<T> {
|
export interface ITreeContextMenuEvent<T> {
|
||||||
browserEvent: UIEvent;
|
readonly browserEvent: UIEvent;
|
||||||
element: T | null;
|
readonly element: T | null;
|
||||||
anchor: HTMLElement | { x: number; y: number };
|
readonly anchor: HTMLElement | { readonly x: number; readonly y: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITreeNavigator<T> {
|
export interface ITreeNavigator<T> {
|
||||||
|
|
|
@ -219,8 +219,8 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
|
||||||
private readonly _onDidCollapseItem: Emitter<ITreeItem> = this._register(new Emitter<ITreeItem>());
|
private readonly _onDidCollapseItem: Emitter<ITreeItem> = this._register(new Emitter<ITreeItem>());
|
||||||
readonly onDidCollapseItem: Event<ITreeItem> = this._onDidCollapseItem.event;
|
readonly onDidCollapseItem: Event<ITreeItem> = this._onDidCollapseItem.event;
|
||||||
|
|
||||||
private _onDidChangeSelection: Emitter<ITreeItem[]> = this._register(new Emitter<ITreeItem[]>());
|
private _onDidChangeSelection: Emitter<readonly ITreeItem[]> = this._register(new Emitter<readonly ITreeItem[]>());
|
||||||
readonly onDidChangeSelection: Event<ITreeItem[]> = this._onDidChangeSelection.event;
|
readonly onDidChangeSelection: Event<readonly ITreeItem[]> = this._onDidChangeSelection.event;
|
||||||
|
|
||||||
private _onDidChangeFocus: Emitter<ITreeItem> = this._register(new Emitter<ITreeItem>());
|
private _onDidChangeFocus: Emitter<ITreeItem> = this._register(new Emitter<ITreeItem>());
|
||||||
readonly onDidChangeFocus: Event<ITreeItem> = this._onDidChangeFocus.event;
|
readonly onDidChangeFocus: Event<ITreeItem> = this._onDidChangeFocus.event;
|
||||||
|
@ -240,8 +240,8 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
|
||||||
private readonly _onDidChangeDescription: Emitter<string | undefined> = this._register(new Emitter<string | undefined>());
|
private readonly _onDidChangeDescription: Emitter<string | undefined> = this._register(new Emitter<string | undefined>());
|
||||||
readonly onDidChangeDescription: Event<string | undefined> = this._onDidChangeDescription.event;
|
readonly onDidChangeDescription: Event<string | undefined> = this._onDidChangeDescription.event;
|
||||||
|
|
||||||
private readonly _onDidChangeCheckboxState: Emitter<ITreeItem[]> = this._register(new Emitter<ITreeItem[]>());
|
private readonly _onDidChangeCheckboxState: Emitter<readonly ITreeItem[]> = this._register(new Emitter<readonly ITreeItem[]>());
|
||||||
readonly onDidChangeCheckboxState: Event<ITreeItem[]> = this._onDidChangeCheckboxState.event;
|
readonly onDidChangeCheckboxState: Event<readonly ITreeItem[]> = this._onDidChangeCheckboxState.event;
|
||||||
|
|
||||||
private readonly _onDidCompleteRefresh: Emitter<void> = this._register(new Emitter<void>());
|
private readonly _onDidCompleteRefresh: Emitter<void> = this._register(new Emitter<void>());
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async refresh(elements?: ITreeItem[]): Promise<void> {
|
async refresh(elements?: readonly ITreeItem[]): Promise<void> {
|
||||||
if (this.dataProvider && this.tree) {
|
if (this.dataProvider && this.tree) {
|
||||||
if (this.refreshing) {
|
if (this.refreshing) {
|
||||||
await Event.toPromise(this._onDidCompleteRefresh.event);
|
await Event.toPromise(this._onDidCompleteRefresh.event);
|
||||||
|
@ -930,7 +930,7 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private refreshing: boolean = false;
|
private refreshing: boolean = false;
|
||||||
private async doRefresh(elements: ITreeItem[]): Promise<void> {
|
private async doRefresh(elements: readonly ITreeItem[]): Promise<void> {
|
||||||
const tree = this.tree;
|
const tree = this.tree;
|
||||||
if (tree && this.visible) {
|
if (tree && this.visible) {
|
||||||
this.refreshing = true;
|
this.refreshing = true;
|
||||||
|
|
|
@ -665,7 +665,7 @@ export interface ITreeView extends IDisposable {
|
||||||
|
|
||||||
readonly onDidCollapseItem: Event<ITreeItem>;
|
readonly onDidCollapseItem: Event<ITreeItem>;
|
||||||
|
|
||||||
readonly onDidChangeSelection: Event<ITreeItem[]>;
|
readonly onDidChangeSelection: Event<readonly ITreeItem[]>;
|
||||||
|
|
||||||
readonly onDidChangeFocus: Event<ITreeItem>;
|
readonly onDidChangeFocus: Event<ITreeItem>;
|
||||||
|
|
||||||
|
@ -679,11 +679,11 @@ export interface ITreeView extends IDisposable {
|
||||||
|
|
||||||
readonly onDidChangeWelcomeState: Event<void>;
|
readonly onDidChangeWelcomeState: Event<void>;
|
||||||
|
|
||||||
readonly onDidChangeCheckboxState: Event<ITreeItem[]>;
|
readonly onDidChangeCheckboxState: Event<readonly ITreeItem[]>;
|
||||||
|
|
||||||
readonly container: any | undefined;
|
readonly container: any | undefined;
|
||||||
|
|
||||||
refresh(treeItems?: ITreeItem[]): Promise<void>;
|
refresh(treeItems?: readonly ITreeItem[]): Promise<void>;
|
||||||
|
|
||||||
setVisibility(visible: boolean): void;
|
setVisibility(visible: boolean): void;
|
||||||
|
|
||||||
|
|
|
@ -609,7 +609,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFocusChanged(elements: ExplorerItem[]): void {
|
private onFocusChanged(elements: readonly ExplorerItem[]): void {
|
||||||
const stat = elements && elements.length ? elements[0] : undefined;
|
const stat = elements && elements.length ? elements[0] : undefined;
|
||||||
this.setContextKeys(stat);
|
this.setContextKeys(stat);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||||
get scrollableElement(): HTMLElement {
|
get scrollableElement(): HTMLElement {
|
||||||
return this.view.scrollableElementDomNode;
|
return this.view.scrollableElementDomNode;
|
||||||
}
|
}
|
||||||
private _previousFocusedElements: CellViewModel[] = [];
|
private _previousFocusedElements: readonly CellViewModel[] = [];
|
||||||
private readonly _localDisposableStore = new DisposableStore();
|
private readonly _localDisposableStore = new DisposableStore();
|
||||||
private readonly _viewModelStore = new DisposableStore();
|
private readonly _viewModelStore = new DisposableStore();
|
||||||
private styleElement?: HTMLStyleElement;
|
private styleElement?: HTMLStyleElement;
|
||||||
|
|
|
@ -949,7 +949,7 @@ export class TunnelPanel extends ViewPane {
|
||||||
|
|
||||||
private onFocusChanged(event: ITableEvent<ITunnelItem>) {
|
private onFocusChanged(event: ITableEvent<ITunnelItem>) {
|
||||||
if (event.indexes.length > 0 && event.elements.length > 0) {
|
if (event.indexes.length > 0 && event.elements.length > 0) {
|
||||||
this.lastFocus = event.indexes;
|
this.lastFocus = [...event.indexes];
|
||||||
}
|
}
|
||||||
const elements = event.elements;
|
const elements = event.elements;
|
||||||
const item = elements && elements.length ? elements[0] : undefined;
|
const item = elements && elements.length ? elements[0] : undefined;
|
||||||
|
|
|
@ -197,7 +197,7 @@ export interface ISCMViewService {
|
||||||
repositories: ISCMRepository[];
|
repositories: ISCMRepository[];
|
||||||
readonly onDidChangeRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
|
readonly onDidChangeRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
|
||||||
|
|
||||||
visibleRepositories: ISCMRepository[];
|
visibleRepositories: readonly ISCMRepository[];
|
||||||
readonly onDidChangeVisibleRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
|
readonly onDidChangeVisibleRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
|
||||||
|
|
||||||
isVisible(repository: ISCMRepository): boolean;
|
isVisible(repository: ISCMRepository): boolean;
|
||||||
|
|
|
@ -873,7 +873,7 @@ abstract class UserDataProfileImportExportState extends Disposable implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDidChangeCheckboxState(items: ITreeItem[]): ITreeItem[] {
|
onDidChangeCheckboxState(items: readonly ITreeItem[]): readonly ITreeItem[] {
|
||||||
const toRefresh: ITreeItem[] = [];
|
const toRefresh: ITreeItem[] = [];
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item.children) {
|
if (item.children) {
|
||||||
|
|
Loading…
Reference in a new issue