提交 21c04900 编写于 作者: I isidor

explorerService: add hasViewFocus and undoRedoSource

上级 49a1f408
......@@ -134,6 +134,7 @@ export class ExplorerView extends ViewPane {
private styleElement!: HTMLStyleElement;
private treeContainer!: HTMLElement;
private container!: HTMLElement;
private compressedFocusContext: IContextKey<boolean>;
private compressedFocusFirstContext: IContextKey<boolean>;
private compressedFocusLastContext: IContextKey<boolean>;
......@@ -245,6 +246,7 @@ export class ExplorerView extends ViewPane {
renderBody(container: HTMLElement): void {
super.renderBody(container);
this.container = container;
this.treeContainer = DOM.append(container, DOM.$('.explorer-folders-view'));
this.styleElement = DOM.createStyleSheet(this.treeContainer);
......@@ -303,6 +305,10 @@ export class ExplorerView extends ViewPane {
}
}
hasFocus(): boolean {
return DOM.isAncestor(document.activeElement, this.container);
}
getContext(respectMultiSelection: boolean): ExplorerItem[] {
return getContext(this.tree.getFocus(), this.tree.getSelection(), respectMultiSelection, this.renderer);
}
......
......@@ -16,11 +16,13 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditableData } from 'vs/workbench/common/views';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { UndoRedoSource } from 'vs/platform/undoRedo/common/undoRedo';
export class ExplorerService implements IExplorerService {
declare readonly _serviceBrand: undefined;
private static readonly EXPLORER_FILE_CHANGES_REACT_DELAY = 500; // delay in ms to react to file changes to give our internal events a chance to react first
private static readonly UNDO_REDO_SOURCE = new UndoRedoSource();
private readonly disposables = new DisposableStore();
private editable: { stat: ExplorerItem, data: IEditableData } | undefined;
......@@ -84,6 +86,14 @@ export class ExplorerService implements IExplorerService {
return this.view.getContext(respectMultiSelection);
}
get undoRedoSource(): UndoRedoSource {
return ExplorerService.UNDO_REDO_SOURCE;
}
hasViewFocus(): boolean {
return !!this.view && this.view.hasFocus();
}
// IExplorerService methods
findClosest(resource: URI): ExplorerItem | null {
......
......@@ -22,6 +22,7 @@ import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { once } from 'vs/base/common/functional';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { UndoRedoSource } from 'vs/platform/undoRedo/common/undoRedo';
/**
* Explorer viewlet id.
......@@ -37,8 +38,10 @@ export interface IExplorerService {
readonly _serviceBrand: undefined;
readonly roots: ExplorerItem[];
readonly sortOrder: SortOrder;
undoRedoSource: UndoRedoSource;
getContext(respectMultiSelection: boolean): ExplorerItem[];
hasViewFocus(): boolean;
setEditable(stat: ExplorerItem, data: IEditableData | null): Promise<void>;
getEditable(): { stat: ExplorerItem, data: IEditableData } | undefined;
getEditableData(stat: ExplorerItem): IEditableData | undefined;
......@@ -67,6 +70,7 @@ export interface IExplorerView {
setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void>;
focusNeighbourIfItemFocused(item: ExplorerItem): void;
isItemVisible(item: ExplorerItem): boolean;
hasFocus(): boolean;
}
export const IExplorerService = createDecorator<IExplorerService>('explorerService');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册