Merge branch 'main' into merogge/letter-key

This commit is contained in:
Megan Rogge
2023-11-03 13:06:54 -07:00
committed by GitHub
29 changed files with 955 additions and 904 deletions
@@ -1860,6 +1860,10 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
return this.model.isCollapsed(location);
}
expandTo(location: TRef): void {
this.model.expandTo(location);
}
triggerTypeNavigation(): void {
this.view.triggerTypeNavigation();
}
@@ -559,6 +559,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.resort(this.getDataNode(element), recursive);
}
hasElement(element: TInput | T): boolean {
return this.tree.hasElement(this.getDataNode(element));
}
hasNode(element: TInput | T): boolean {
return element === this.root.element || this.nodes.has(element as T);
}
@@ -575,6 +579,11 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.rerender(node);
}
updateElementHeight(element: T, height: number | undefined): void {
const node = this.getDataNode(element);
this.tree.updateElementHeight(node, height);
}
updateWidth(element: T): void {
const node = this.getDataNode(element);
this.tree.updateWidth(node);
@@ -636,6 +645,28 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.expandAll();
}
async expandTo(element: T): Promise<void> {
if (!this.dataSource.getParent) {
throw new Error('Can\'t expand to element without getParent method');
}
const elements: T[] = [];
while (!this.hasNode(element)) {
element = this.dataSource.getParent(element) as T;
if (element !== this.root.element) {
elements.push(element);
}
}
for (const element of Iterable.reverse(elements)) {
await this.expand(element);
}
this.tree.expandTo(this.getDataNode(element));
}
collapseAll(): void {
this.tree.collapseAll();
}
+1
View File
@@ -196,6 +196,7 @@ export interface IDataSource<TInput, T> {
export interface IAsyncDataSource<TInput, T> {
hasChildren(element: TInput | T): boolean;
getChildren(element: TInput | T): Iterable<T> | Promise<Iterable<T>>;
getParent?(element: T): TInput | T;
}
export const enum TreeDragOverBubble {
+4
View File
@@ -748,6 +748,10 @@ export class DisposableMap<K, V extends IDisposable = IDisposable> implements ID
this._store.delete(key);
}
keys(): IterableIterator<K> {
return this._store.keys();
}
[Symbol.iterator](): IterableIterator<[K, V]> {
return this._store[Symbol.iterator]();
}
+1 -1
View File
@@ -1800,7 +1800,7 @@ export interface Comment {
export interface PendingCommentThread {
body: string;
range: IRange;
range: IRange | undefined;
uri: URI;
owner: string;
isReply: boolean;
+1 -1
View File
@@ -7650,7 +7650,7 @@ declare namespace monaco.languages {
export interface PendingCommentThread {
body: string;
range: IRange;
range: IRange | undefined;
uri: Uri;
owner: string;
isReply: boolean;
+43 -18
View File
@@ -10,13 +10,14 @@ import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGr
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, SCMHistoryItemDto, SCMActionButtonDto, SCMHistoryItemGroupDto, SCMInputActionButtonDto } from '../common/extHost.protocol';
import { Command } from 'vs/editor/common/languages';
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { ISplice, Sequence } from 'vs/base/common/sequence';
import { CancellationToken } from 'vs/base/common/cancellation';
import { MarshalledId } from 'vs/base/common/marshallingIds';
import { ThemeIcon } from 'vs/base/common/themables';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { IQuickDiffService, QuickDiffProvider } from 'vs/workbench/contrib/scm/common/quickDiff';
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGroup, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
import { ResourceTree } from 'vs/base/common/resourceTree';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
function getSCMInputBoxActionButtonIcon(actionButton: SCMInputActionButtonDto): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (!actionButton.icon) {
@@ -46,23 +47,37 @@ function getSCMHistoryItemIcon(historyItem: SCMHistoryItemDto): URI | { light: U
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
readonly elements: ISCMResource[] = [];
readonly resources: ISCMResource[] = [];
private readonly _onDidSplice = new Emitter<ISplice<ISCMResource>>();
readonly onDidSplice = this._onDidSplice.event;
private _resourceTree: ResourceTree<ISCMResource, ISCMResourceGroup> | undefined;
get resourceTree(): ResourceTree<ISCMResource, ISCMResourceGroup> {
if (!this._resourceTree) {
const rootUri = this.provider.rootUri ?? URI.file('/');
this._resourceTree = new ResourceTree<ISCMResource, ISCMResourceGroup>(this, rootUri, this._uriIdentService.extUri);
for (const resource of this.resources) {
this._resourceTree.add(resource.sourceUri, resource);
}
}
get hideWhenEmpty(): boolean { return !!this.features.hideWhenEmpty; }
return this._resourceTree;
}
private readonly _onDidChange = new Emitter<void>();
readonly onDidChange: Event<void> = this._onDidChange.event;
private readonly _onDidChangeResources = new Emitter<void>();
readonly onDidChangeResources = this._onDidChangeResources.event;
get hideWhenEmpty(): boolean { return !!this.features.hideWhenEmpty; }
constructor(
private readonly sourceControlHandle: number,
private readonly handle: number,
public provider: ISCMProvider,
public features: SCMGroupFeatures,
public label: string,
public id: string
public id: string,
private readonly _uriIdentService: IUriIdentityService
) { }
toJSON(): any {
@@ -74,8 +89,10 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
}
splice(start: number, deleteCount: number, toInsert: ISCMResource[]) {
this.elements.splice(start, deleteCount, ...toInsert);
this._onDidSplice.fire({ start, deleteCount, toInsert });
this.resources.splice(start, deleteCount, ...toInsert);
this._resourceTree = undefined;
this._onDidChangeResources.fire();
}
$updateGroup(features: SCMGroupFeatures): void {
@@ -172,7 +189,13 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
private _id = `scm${MainThreadSCMProvider.ID_HANDLE++}`;
get id(): string { return this._id; }
readonly groups = new Sequence<MainThreadSCMResourceGroup>();
readonly groups: MainThreadSCMResourceGroup[] = [];
private readonly _onDidChangeResourceGroups = new Emitter<void>();
readonly onDidChangeResourceGroups = this._onDidChangeResourceGroups.event;
private readonly _onDidChangeResources = new Emitter<void>();
readonly onDidChangeResources = this._onDidChangeResources.event;
private readonly _groupsByHandle: { [handle: number]: MainThreadSCMResourceGroup } = Object.create(null);
// get groups(): ISequence<ISCMResourceGroup> {
@@ -185,8 +208,6 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
// // .filter(g => g.resources.elements.length > 0 || !g.features.hideWhenEmpty);
// }
private readonly _onDidChangeResources = new Emitter<void>();
readonly onDidChangeResources: Event<void> = this._onDidChangeResources.event;
private features: SCMProviderFeatures = {};
@@ -227,7 +248,8 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
private readonly _label: string,
private readonly _rootUri: URI | undefined,
private readonly _inputBoxDocumentUri: URI,
private readonly _quickDiffService: IQuickDiffService
private readonly _quickDiffService: IQuickDiffService,
private readonly _uriIdentService: IUriIdentityService
) { }
$updateSourceControl(features: SCMProviderFeatures): void {
@@ -271,14 +293,16 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
this,
features,
label,
id
id,
this._uriIdentService
);
this._groupsByHandle[handle] = group;
return group;
});
this.groups.splice(this.groups.elements.length, 0, groups);
this.groups.splice(this.groups.length, 0, ...groups);
this._onDidChangeResourceGroups.fire();
}
$updateGroup(handle: number, features: SCMGroupFeatures): void {
@@ -357,8 +381,8 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
}
delete this._groupsByHandle[handle];
this.groups.splice(this.groups.elements.indexOf(group), 1);
this._onDidChangeResources.fire();
this.groups.splice(this.groups.indexOf(group), 1);
this._onDidChangeResourceGroups.fire();
}
async getOriginalResource(uri: URI): Promise<URI | null> {
@@ -410,7 +434,8 @@ export class MainThreadSCM implements MainThreadSCMShape {
extHostContext: IExtHostContext,
@ISCMService private readonly scmService: ISCMService,
@ISCMViewService private readonly scmViewService: ISCMViewService,
@IQuickDiffService private readonly quickDiffService: IQuickDiffService
@IQuickDiffService private readonly quickDiffService: IQuickDiffService,
@IUriIdentityService private readonly _uriIdentService: IUriIdentityService
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostSCM);
}
@@ -426,7 +451,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
}
$registerSourceControl(handle: number, id: string, label: string, rootUri: UriComponents | undefined, inputBoxDocumentUri: UriComponents): void {
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri ? URI.revive(rootUri) : undefined, URI.revive(inputBoxDocumentUri), this.quickDiffService);
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri ? URI.revive(rootUri) : undefined, URI.revive(inputBoxDocumentUri), this.quickDiffService, this._uriIdentService);
const repository = this.scmService.registerSCMProvider(provider);
this._repositories.set(handle, repository);
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
import { MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ActivityBarPosition, IWorkbenchLayoutService, LayoutSettings, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService';
import { IWorkbenchLayoutService, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes';
import { isWindows, isLinux, isWeb, isMacintosh, isNative } from 'vs/base/common/platform';
@@ -67,30 +67,7 @@ registerAction2(class extends Action2 {
}
});
// --- Toggle Activity Bar
export class ToggleActivityBarVisibilityAction extends Action2 {
static readonly ID = 'workbench.action.toggleActivityBarVisibility';
constructor() {
super({
id: ToggleActivityBarVisibilityAction.ID,
title: {
value: localize('toggleActivityBar', "Toggle Activity Bar Visibility"),
original: 'Toggle Activity Bar Visibility'
},
});
}
run(accessor: ServicesAccessor): void {
const configurationService = accessor.get(IConfigurationService);
const value = configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION);
configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, value === ActivityBarPosition.HIDDEN ? undefined : ActivityBarPosition.HIDDEN);
}
}
registerAction2(ToggleActivityBarVisibilityAction);
export const ToggleActivityBarVisibilityActionId = 'workbench.action.toggleActivityBarVisibility';
// --- Toggle Centered Layout
@@ -1223,7 +1200,7 @@ if (!isMacintosh || !isNative) {
}
ToggleVisibilityActions.push(...[
CreateToggleLayoutItem(ToggleActivityBarVisibilityAction.ID, ContextKeyExpr.equals('config.workbench.activityBar.visible', true), localize('activityBar', "Activity Bar"), { whenA: ContextKeyExpr.equals('config.workbench.sideBar.location', 'left'), iconA: activityBarLeftIcon, iconB: activityBarRightIcon }),
CreateToggleLayoutItem(ToggleActivityBarVisibilityActionId, ContextKeyExpr.equals('config.workbench.activityBar.visible', true), localize('activityBar', "Activity Bar"), { whenA: ContextKeyExpr.equals('config.workbench.sideBar.location', 'left'), iconA: activityBarLeftIcon, iconB: activityBarRightIcon }),
CreateToggleLayoutItem(ToggleSidebarVisibilityAction.ID, SideBarVisibleContext, localize('sideBar', "Primary Side Bar"), { whenA: ContextKeyExpr.equals('config.workbench.sideBar.location', 'left'), iconA: panelLeftIcon, iconB: panelRightIcon }),
CreateToggleLayoutItem(ToggleAuxiliaryBarAction.ID, AuxiliaryBarVisibleContext, localize('secondarySideBar', "Secondary Side Bar"), { whenA: ContextKeyExpr.equals('config.workbench.sideBar.location', 'left'), iconA: panelRightIcon, iconB: panelLeftIcon }),
CreateToggleLayoutItem(TogglePanelAction.ID, PanelVisibleContext, localize('panel', "Panel"), panelIcon),
@@ -134,20 +134,22 @@ export class ActivitybarPart extends Part {
container.style.borderColor = borderColor ? borderColor : '';
}
show(): void {
show(focus?: boolean): void {
if (!this.content) {
return;
}
if (this.compositeBar.value) {
return;
if (!this.compositeBar.value) {
this.compositeBar.value = this.createCompositeBar();
this.compositeBar.value.create(this.content);
if (this.dimension) {
this.layout(this.dimension.width, this.dimension.height);
}
}
this.compositeBar.value = this.createCompositeBar();
this.compositeBar.value.create(this.content);
if (this.dimension) {
this.layout(this.dimension.width, this.dimension.height);
if (focus) {
this.focus();
}
}
@@ -7,7 +7,7 @@ import 'vs/css!./media/sidebarpart';
import 'vs/workbench/browser/parts/sidebar/sidebarActions';
import { ActivityBarPosition, IWorkbenchLayoutService, LayoutSettings, Parts, Position as SideBarPosition } from 'vs/workbench/services/layout/browser/layoutService';
import { SidebarFocusContext, ActiveViewletContext } from 'vs/workbench/common/contextkeys';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -33,6 +33,7 @@ import { ACCOUNTS_ACTIVITY_ID, GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/ac
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Separator } from 'vs/base/common/actions';
import { ToggleActivityBarVisibilityActionId } from 'vs/workbench/browser/actions/layoutActions';
export class SidebarPart extends AbstractPaneCompositePart {
@@ -105,17 +106,14 @@ export class SidebarPart extends AbstractPaneCompositePart {
);
this.acitivityBarPart = this._register(instantiationService.createInstance(ActivitybarPart, this));
this.rememberActivityBarVisiblePosition();
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(LayoutSettings.ACTIVITY_BAR_LOCATION)) {
this.updateTitleArea();
const id = this.getActiveComposite()?.getId();
if (id) {
this.onTitleAreaUpdate(id!);
}
this.updateActivityBarVisiblity();
this.onDidChangeActivityBarLocation();
}
}));
this.registerActions();
this.registerGlobalActions();
lifecycleService.when(LifecyclePhase.Eventually).then(() => {
@@ -127,6 +125,16 @@ export class SidebarPart extends AbstractPaneCompositePart {
});
}
private onDidChangeActivityBarLocation(): void {
this.updateTitleArea();
const id = this.getActiveComposite()?.getId();
if (id) {
this.onTitleAreaUpdate(id!);
}
this.updateActivityBarVisiblity();
this.rememberActivityBarVisiblePosition();
}
override updateStyles(): void {
super.updateStyles();
@@ -210,6 +218,21 @@ export class SidebarPart extends AbstractPaneCompositePart {
return this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) !== ActivityBarPosition.HIDDEN;
}
private rememberActivityBarVisiblePosition(): void {
const activityBarPosition = this.configurationService.getValue<string>(LayoutSettings.ACTIVITY_BAR_LOCATION);
if (activityBarPosition !== ActivityBarPosition.HIDDEN) {
this.storageService.store(LayoutSettings.ACTIVITY_BAR_LOCATION, activityBarPosition, StorageScope.PROFILE, StorageTarget.USER);
}
}
private getRememberedActivityBarVisiblePosition(): ActivityBarPosition {
const activityBarPosition = this.storageService.get(LayoutSettings.ACTIVITY_BAR_LOCATION, StorageScope.PROFILE);
switch (activityBarPosition) {
case ActivityBarPosition.SIDE: return ActivityBarPosition.SIDE;
default: return ActivityBarPosition.TOP;
}
}
private updateActivityBarVisiblity(): void {
if (this.shouldShowActivityBar()) {
this.acitivityBarPart.show();
@@ -226,17 +249,40 @@ export class SidebarPart extends AbstractPaneCompositePart {
return this.shouldShowCompositeBar() ? super.getVisiblePaneCompositeIds() : this.acitivityBarPart.getVisiblePaneCompositeIds();
}
focusActivityBar(): void {
async focusActivityBar(): Promise<void> {
if (this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) === ActivityBarPosition.HIDDEN) {
await this.configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, this.getRememberedActivityBarVisiblePosition());
this.onDidChangeActivityBarLocation();
}
if (this.shouldShowCompositeBar()) {
this.focusComositeBar();
} else {
if (!this.layoutService.isVisible(Parts.ACTIVITYBAR_PART)) {
this.layoutService.setPartHidden(false, Parts.ACTIVITYBAR_PART);
}
this.acitivityBarPart.focus();
this.acitivityBarPart.show(true);
}
}
private registerActions(): void {
const that = this;
this._register(registerAction2(class extends Action2 {
constructor() {
super({
id: ToggleActivityBarVisibilityActionId,
title: {
value: localize('toggleActivityBar', "Toggle Activity Bar Visibility"),
original: 'Toggle Activity Bar Visibility'
},
});
}
run(): Promise<void> {
const value = that.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) === ActivityBarPosition.HIDDEN ? that.getRememberedActivityBarVisiblePosition() : ActivityBarPosition.HIDDEN;
return that.configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, value);
}
}));
}
private registerGlobalActions() {
this._register(registerAction2(
class extends Action2 {
@@ -105,7 +105,7 @@ export interface ICommentService {
setCurrentCommentThread(commentThread: CommentThread<IRange | ICellRange> | undefined): void;
enableCommenting(enable: boolean): void;
registerContinueOnCommentProvider(provider: IContinueOnCommentProvider): IDisposable;
removeContinueOnComment(pendingComment: { range: IRange; uri: URI; owner: string; isReply?: boolean }): PendingCommentThread | undefined;
removeContinueOnComment(pendingComment: { range: IRange | undefined; uri: URI; owner: string; isReply?: boolean }): PendingCommentThread | undefined;
}
const CONTINUE_ON_COMMENTS = 'comments.continueOnComments';
@@ -465,7 +465,7 @@ export class CommentController implements IEditorContribution {
for (const zone of this._commentWidgets) {
const zonePendingComments = zone.getPendingComments();
const pendingNewComment = zonePendingComments.newComment;
if (!pendingNewComment || !zone.commentThread.range) {
if (!pendingNewComment) {
continue;
}
let lastCommentBody;
@@ -842,7 +842,13 @@ export class CommentController implements IEditorContribution {
return;
}
const continueOnCommentIndex = this._inProcessContinueOnComments.get(e.owner)?.findIndex(pending => Range.lift(pending.range).equalsRange(thread.range));
const continueOnCommentIndex = this._inProcessContinueOnComments.get(e.owner)?.findIndex(pending => {
if (pending.range === undefined) {
return thread.range === undefined;
} else {
return Range.lift(pending.range).equalsRange(thread.range);
}
});
let continueOnCommentText: string | undefined;
if ((continueOnCommentIndex !== undefined) && continueOnCommentIndex >= 0) {
continueOnCommentText = this._inProcessContinueOnComments.get(e.owner)?.splice(continueOnCommentIndex, 1)[0].body;
@@ -892,7 +898,7 @@ export class CommentController implements IEditorContribution {
this._inProcessContinueOnComments.set(thread.owner, []);
}
this._inProcessContinueOnComments.get(thread.owner)?.push(thread);
await this.commentService.createCommentThreadTemplate(thread.owner, thread.uri, Range.lift(thread.range));
await this.commentService.createCommentThreadTemplate(thread.owner, thread.uri, thread.range ? Range.lift(thread.range) : undefined);
}
}
@@ -788,8 +788,8 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
}
private getChangedResources(repository: ISCMRepository) {
return repository.provider.groups.elements.reduce((resources, resourceGroups) => {
resourceGroups.elements.forEach((resource) => resources.add(resource.sourceUri));
return repository.provider.groups.reduce((resources, resourceGroups) => {
resourceGroups.resources.forEach((resource) => resources.add(resource.sourceUri));
return resources;
}, new Set<URI>()); // A URI might appear in more than one resource group
}
@@ -281,7 +281,7 @@ export class FindModel extends Disposable {
const index = this._notebookEditor.getCellIndex(findMatch.cell);
if (index !== undefined) {
// const range: ICellRange = { start: index, end: index + 1 };
this._notebookEditor.revealCellOffsetInCenterAsync(findMatch.cell, outputOffset ?? 0);
this._notebookEditor.revealCellOffsetInCenter(findMatch.cell, outputOffset ?? 0);
}
} else {
const match = findMatch.getMatch(matchIndex) as FindMatch;
@@ -326,12 +326,13 @@ export interface INotebookDeltaCellStatusBarItems {
readonly items: readonly INotebookCellStatusBarItem[];
}
export const enum CellRevealSyncType {
export const enum CellRevealType {
Default = 1,
Top = 2,
Center = 3,
CenterIfOutsideViewport = 4,
FirstLineIfOutsideViewport = 5
NearTopIfOutsideViewport = 5,
FirstLineIfOutsideViewport = 6
}
export enum CellRevealRangeType {
@@ -340,11 +341,6 @@ export enum CellRevealRangeType {
CenterIfOutsideViewport = 3,
}
export enum CellRevealType {
NearTopIfOutsideViewport,
CenterIfOutsideViewport
}
export interface INotebookEditorOptions extends ITextEditorOptions {
readonly cellOptions?: ITextResourceEditorInput;
readonly cellRevealType?: CellRevealType;
@@ -642,7 +638,7 @@ export interface INotebookEditor {
/**
* Reveal a position with `offset` in a cell into viewport center.
*/
revealCellOffsetInCenterAsync(cell: ICellViewModel, offset: number): Promise<void>;
revealCellOffsetInCenter(cell: ICellViewModel, offset: number): void;
/**
* Convert the view range to model range
@@ -52,7 +52,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { contrastBorder, errorForeground, focusBorder, foreground, listInactiveSelectionBackground, registerColor, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, transparent } from 'vs/platform/theme/common/colorRegistry';
import { EDITOR_PANE_BACKGROUND, PANEL_BORDER, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { debugIconStartForeground } from 'vs/workbench/contrib/debug/browser/debugColors';
import { CellEditState, CellFindMatchWithIndex, CellFocusMode, CellLayoutContext, CellRevealRangeType, CellRevealSyncType, CellRevealType, IActiveNotebookEditorDelegate, IBaseCellEditorOptions, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IInsetRenderOutput, IModelDecorationsChangeAccessor, INotebookDeltaDecoration, INotebookEditor, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorDelegate, INotebookEditorMouseEvent, INotebookEditorOptions, INotebookEditorViewState, INotebookViewCellsUpdateEvent, INotebookWebviewMessage, RenderOutputType, ScrollToRevealBehavior } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellEditState, CellFindMatchWithIndex, CellFocusMode, CellLayoutContext, CellRevealRangeType, CellRevealType, IActiveNotebookEditorDelegate, IBaseCellEditorOptions, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IInsetRenderOutput, IModelDecorationsChangeAccessor, INotebookDeltaDecoration, INotebookEditor, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorDelegate, INotebookEditorMouseEvent, INotebookEditorOptions, INotebookEditorViewState, INotebookViewCellsUpdateEvent, INotebookWebviewMessage, RenderOutputType, ScrollToRevealBehavior } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { notebookDebug } from 'vs/workbench/contrib/notebook/browser/notebookLogger';
@@ -1231,10 +1231,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
cell.updateEditState(CellEditState.Editing, 'setOptions');
cell.focusMode = CellFocusMode.Editor;
await this.revealRangeInCenterIfOutsideViewportAsync(cell, new Range(selection.startLineNumber, selection.startColumn, selection.endLineNumber || selection.startLineNumber, selection.endColumn || selection.startColumn));
} else if (options?.cellRevealType === CellRevealType.NearTopIfOutsideViewport) {
await this._list.revealCellAsync(cell, CellRevealType.NearTopIfOutsideViewport);
} else {
await this._list.revealCellAsync(cell, CellRevealType.CenterIfOutsideViewport);
this._list.revealCell(cell, options?.cellRevealType ?? CellRevealType.CenterIfOutsideViewport);
}
const editor = this._renderedEditors.get(cell)!;
@@ -2058,55 +2056,55 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
}
revealCellRangeInView(range: ICellRange) {
return this._list.revealCellsInView(range);
return this._list.revealCells(range);
}
revealInView(cell: ICellViewModel) {
this._list.revealCell(cell, CellRevealSyncType.Default);
this._list.revealCell(cell, CellRevealType.Default);
}
revealInViewAtTop(cell: ICellViewModel) {
this._list.revealCell(cell, CellRevealSyncType.Top);
this._list.revealCell(cell, CellRevealType.Top);
}
revealInCenter(cell: ICellViewModel) {
this._list.revealCell(cell, CellRevealSyncType.Center);
this._list.revealCell(cell, CellRevealType.Center);
}
revealInCenterIfOutsideViewport(cell: ICellViewModel) {
this._list.revealCell(cell, CellRevealSyncType.CenterIfOutsideViewport);
this._list.revealCell(cell, CellRevealType.CenterIfOutsideViewport);
}
revealFirstLineIfOutsideViewport(cell: ICellViewModel) {
this._list.revealCell(cell, CellRevealSyncType.FirstLineIfOutsideViewport);
this._list.revealCell(cell, CellRevealType.FirstLineIfOutsideViewport);
}
async revealLineInViewAsync(cell: ICellViewModel, line: number): Promise<void> {
return this._list.revealCellRangeAsync(cell, new Range(line, 1, line, 1), CellRevealRangeType.Default);
return this._list.revealRangeInCell(cell, new Range(line, 1, line, 1), CellRevealRangeType.Default);
}
async revealLineInCenterAsync(cell: ICellViewModel, line: number): Promise<void> {
return this._list.revealCellRangeAsync(cell, new Range(line, 1, line, 1), CellRevealRangeType.Center);
return this._list.revealRangeInCell(cell, new Range(line, 1, line, 1), CellRevealRangeType.Center);
}
async revealLineInCenterIfOutsideViewportAsync(cell: ICellViewModel, line: number): Promise<void> {
return this._list.revealCellRangeAsync(cell, new Range(line, 1, line, 1), CellRevealRangeType.CenterIfOutsideViewport);
return this._list.revealRangeInCell(cell, new Range(line, 1, line, 1), CellRevealRangeType.CenterIfOutsideViewport);
}
async revealRangeInViewAsync(cell: ICellViewModel, range: Selection | Range): Promise<void> {
return this._list.revealCellRangeAsync(cell, range, CellRevealRangeType.Default);
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.Default);
}
async revealRangeInCenterAsync(cell: ICellViewModel, range: Selection | Range): Promise<void> {
return this._list.revealCellRangeAsync(cell, range, CellRevealRangeType.Center);
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.Center);
}
async revealRangeInCenterIfOutsideViewportAsync(cell: ICellViewModel, range: Selection | Range): Promise<void> {
return this._list.revealCellRangeAsync(cell, range, CellRevealRangeType.CenterIfOutsideViewport);
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.CenterIfOutsideViewport);
}
async revealCellOffsetInCenterAsync(cell: ICellViewModel, offset: number): Promise<void> {
return this._list.revealCellOffsetInCenterAsync(cell, offset);
revealCellOffsetInCenter(cell: ICellViewModel, offset: number) {
return this._list.revealCellOffsetInCenter(cell, offset);
}
getViewIndexByModelIndex(index: number): number {
@@ -2341,9 +2339,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const selectionsStartPosition = cell.getSelectionsStartPosition();
if (selectionsStartPosition?.length) {
const firstSelectionPosition = selectionsStartPosition[0];
await this.revealRangeInCenterIfOutsideViewportAsync(cell, Range.fromPositions(firstSelectionPosition, firstSelectionPosition));
await this.revealRangeInViewAsync(cell, Range.fromPositions(firstSelectionPosition, firstSelectionPosition));
} else {
this.revealInCenterIfOutsideViewport(cell);
this.revealInView(cell);
}
}
@@ -18,7 +18,7 @@ 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 { IListService, IWorkbenchListOptions, WorkbenchList } from 'vs/platform/list/browser/listService';
import { CursorAtBoundary, ICellViewModel, CellEditState, CellFocusMode, ICellOutputViewModel, CellRevealType, CellRevealSyncType, CellRevealRangeType, CursorAtLineBoundary } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CursorAtBoundary, ICellViewModel, CellEditState, CellFocusMode, ICellOutputViewModel, CellRevealType, CellRevealRangeType, CursorAtLineBoundary } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl';
import { diff, NOTEBOOK_EDITOR_CURSOR_BOUNDARY, CellKind, SelectionStateType, NOTEBOOK_EDITOR_CURSOR_LINE_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ICellRange, cellRangesToIndexes, reduceCellRanges, cellRangesEqual } from 'vs/workbench/contrib/notebook/common/notebookRange';
@@ -35,11 +35,6 @@ import { NotebookOptions } from 'vs/workbench/contrib/notebook/browser/notebookO
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { NotebookCellAnchor } from 'vs/workbench/contrib/notebook/browser/view/notebookCellAnchor';
const enum CellEditorRevealType {
Line,
Range
}
const enum CellRevealPosition {
Top,
Center,
@@ -790,7 +785,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
/**
* The range will be revealed with as little scrolling as possible.
*/
revealCellsInView(range: ICellRange) {
revealCells(range: ICellRange) {
const startIndex = this._getViewIndexUpperBound2(range.start);
if (startIndex < 0) {
@@ -853,8 +848,12 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
this.view.setScrollTop(scrollHeight - (wrapperBottom - scrollTop));
}
//#region Reveal Cell synchronously
revealCell(cell: ICellViewModel, revealType: CellRevealSyncType) {
/**
* Reveals the given cell in the notebook cell list. The cell will come into view syncronously
* but the cell's editor will be attached asyncronously if it was previously out of view.
* @returns The promise to await for the cell editor to be attached
*/
async revealCell(cell: ICellViewModel, revealType: CellRevealType): Promise<void> {
const index = this._getViewIndexUpperBound(cell);
if (index < 0) {
@@ -862,22 +861,32 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
}
switch (revealType) {
case CellRevealSyncType.Top:
case CellRevealType.Top:
this._revealInternal(index, false, CellRevealPosition.Top);
break;
case CellRevealSyncType.Center:
case CellRevealType.Center:
this._revealInternal(index, false, CellRevealPosition.Center);
break;
case CellRevealSyncType.CenterIfOutsideViewport:
case CellRevealType.CenterIfOutsideViewport:
this._revealInternal(index, true, CellRevealPosition.Center);
break;
case CellRevealSyncType.FirstLineIfOutsideViewport:
case CellRevealType.NearTopIfOutsideViewport:
this._revealInternal(index, true, CellRevealPosition.NearTop);
break;
case CellRevealType.FirstLineIfOutsideViewport:
this._revealInViewWithMinimalScrolling(index, true);
break;
case CellRevealSyncType.Default:
case CellRevealType.Default:
this._revealInViewWithMinimalScrolling(index);
break;
}
// wait for the editor to be created only if the cell is in editing mode (meaning it has an editor and will focus the editor)
if (cell.getEditState() === CellEditState.Editing && !cell.editorAttached) {
return getEditorAttachedPromise(cell);
}
return;
}
private _revealInternal(viewIndex: number, ignoreIfInsideViewport: boolean, revealPosition: CellRevealPosition, firstLine?: boolean) {
@@ -942,31 +951,8 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
}
}
//#endregion
//#region Reveal Cell asynchronously
async revealCellAsync(cell: ICellViewModel, revealType: CellRevealType) {
const viewIndex = this._getViewIndexUpperBound(cell);
if (viewIndex < 0) {
return;
}
const revealPosition = revealType === CellRevealType.NearTopIfOutsideViewport ? CellRevealPosition.NearTop : CellRevealPosition.Center;
this._revealInternal(viewIndex, true, revealPosition);
// wait for the editor to be created only if the cell is in editing mode (meaning it has an editor and will focus the editor)
if (cell.getEditState() === CellEditState.Editing && !cell.editorAttached) {
return getEditorAttachedPromise(cell);
}
return;
}
//#endregion
//#region Reveal Cell Editor Range asynchronously
async revealCellRangeAsync(cell: ICellViewModel, range: Selection | Range, revealType: CellRevealRangeType): Promise<void> {
async revealRangeInCell(cell: ICellViewModel, range: Selection | Range, revealType: CellRevealRangeType): Promise<void> {
const index = this._getViewIndexUpperBound(cell);
if (index < 0) {
@@ -975,34 +961,34 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
switch (revealType) {
case CellRevealRangeType.Default:
return this._revealRangeInternalAsync(index, range, CellEditorRevealType.Range);
return this._revealRangeInternalAsync(index, range);
case CellRevealRangeType.Center:
return this._revealRangeInCenterInternalAsync(index, range, CellEditorRevealType.Range);
return this._revealRangeInCenterInternalAsync(index, range);
case CellRevealRangeType.CenterIfOutsideViewport:
return this._revealRangeInCenterIfOutsideViewportInternalAsync(index, range, CellEditorRevealType.Range);
return this._revealRangeInCenterIfOutsideViewportInternalAsync(index, range);
}
}
// List items have real dynamic heights, which means after we set `scrollTop` based on the `elementTop(index)`, the element at `index` might still be removed from the view once all relayouting tasks are done.
// For example, we scroll item 10 into the view upwards, in the first round, items 7, 8, 9, 10 are all in the viewport. Then item 7 and 8 resize themselves to be larger and finally item 10 is removed from the view.
// To ensure that item 10 is always there, we need to scroll item 10 to the top edge of the viewport.
private async _revealRangeInternalAsync(viewIndex: number, range: Selection | Range, revealType: CellEditorRevealType): Promise<void> {
private async _revealRangeInternalAsync(viewIndex: number, range: Selection | Range): Promise<void> {
const scrollTop = this.getViewScrollTop();
const wrapperBottom = this.getViewScrollBottom();
const elementTop = this.view.elementTop(viewIndex);
const element = this.view.element(viewIndex);
if (element.editorAttached) {
this._revealRangeCommon(viewIndex, range, revealType, false, false);
this._revealRangeCommon(viewIndex, range, false, false);
} else {
const elementHeight = this.view.elementHeight(viewIndex);
let upwards = false;
if (elementTop + elementHeight < scrollTop) {
if (elementTop + elementHeight <= scrollTop) {
// scroll downwards
this.view.setScrollTop(elementTop);
upwards = false;
} else if (elementTop > wrapperBottom) {
} else if (elementTop >= wrapperBottom) {
// scroll upwards
this.view.setScrollTop(elementTop - this.view.renderHeight / 2);
upwards = true;
@@ -1015,21 +1001,18 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
});
return editorAttachedPromise.then(() => {
this._revealRangeCommon(viewIndex, range, revealType, true, upwards);
this._revealRangeCommon(viewIndex, range, true, upwards);
});
}
}
private async _revealRangeInCenterInternalAsync(viewIndex: number, range: Selection | Range, revealType: CellEditorRevealType): Promise<void> {
const reveal = (viewIndex: number, range: Range, revealType: CellEditorRevealType) => {
private async _revealRangeInCenterInternalAsync(viewIndex: number, range: Selection | Range): Promise<void> {
const reveal = (viewIndex: number, range: Range) => {
const element = this.view.element(viewIndex);
const positionOffset = element.getPositionScrollTopOffset(range);
const positionOffsetInView = this.view.elementTop(viewIndex) + positionOffset;
this.view.setScrollTop(positionOffsetInView - this.view.renderHeight / 2);
if (revealType === CellEditorRevealType.Range) {
element.revealRangeInCenter(range);
}
element.revealRangeInCenter(range);
};
const elementTop = this.view.elementTop(viewIndex);
@@ -1038,22 +1021,20 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
const element = this.view.element(viewIndex);
if (!element.editorAttached) {
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range, revealType));
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range));
} else {
reveal(viewIndex, range, revealType);
reveal(viewIndex, range);
}
}
private async _revealRangeInCenterIfOutsideViewportInternalAsync(viewIndex: number, range: Selection | Range, revealType: CellEditorRevealType): Promise<void> {
const reveal = (viewIndex: number, range: Range, revealType: CellEditorRevealType) => {
private async _revealRangeInCenterIfOutsideViewportInternalAsync(viewIndex: number, range: Selection | Range): Promise<void> {
const reveal = (viewIndex: number, range: Range) => {
const element = this.view.element(viewIndex);
const positionOffset = element.getPositionScrollTopOffset(range);
const positionOffsetInView = this.view.elementTop(viewIndex) + positionOffset;
this.view.setScrollTop(positionOffsetInView - this.view.renderHeight / 2);
if (revealType === CellEditorRevealType.Range) {
element.revealRangeInCenter(range);
}
element.revealRangeInCenter(range);
};
const scrollTop = this.getViewScrollTop();
@@ -1073,7 +1054,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
// reveal editor
if (!element.editorAttached) {
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range, revealType));
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range));
} else {
// for example markdown
}
@@ -1082,12 +1063,12 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
element.revealRangeInCenter(range);
} else {
// for example, markdown cell in preview mode
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range, revealType));
return getEditorAttachedPromise(element).then(() => reveal(viewIndex, range));
}
}
}
private _revealRangeCommon(viewIndex: number, range: Selection | Range, revealType: CellEditorRevealType, newlyCreated: boolean, alignToBottom: boolean) {
private _revealRangeCommon(viewIndex: number, range: Selection | Range, newlyCreated: boolean, alignToBottom: boolean) {
const element = this.view.element(viewIndex);
const scrollTop = this.getViewScrollTop();
const wrapperBottom = this.getViewScrollBottom();
@@ -1120,14 +1101,17 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
}
}
if (revealType === CellEditorRevealType.Range) {
element.revealRangeInCenter(range);
}
element.revealRangeInCenter(range);
}
//#endregion
//#region Reveal Cell offset
async revealCellOffsetInCenterAsync(cell: ICellViewModel, offset: number): Promise<void> {
/**
* Reveals the specified offset of the given cell in the center of the viewport.
* This enables revealing locations in the output as well as the input.
*/
revealCellOffsetInCenter(cell: ICellViewModel, offset: number) {
const viewIndex = this._getViewIndexUpperBound(cell);
if (viewIndex >= 0) {
@@ -1147,8 +1131,6 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
this._revealInternal(viewIndex, true, CellRevealPosition.Center);
}
//#endregion
domElementOfElement(element: ICellViewModel): HTMLElement | null {
const index = this._getViewIndexUpperBound(element);
if (index >= 0) {
@@ -16,7 +16,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkbenchListOptionsUpdate } from 'vs/platform/list/browser/listService';
import { CellRevealRangeType, CellRevealSyncType, CellRevealType, ICellOutputViewModel, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellRevealRangeType, CellRevealType, ICellOutputViewModel, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellPartsCollection } from 'vs/workbench/contrib/notebook/browser/view/cellPart';
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl';
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
@@ -65,12 +65,11 @@ export interface INotebookCellList {
selectElements(elements: ICellViewModel[]): void;
getFocusedElements(): ICellViewModel[];
getSelectedElements(): ICellViewModel[];
revealCellsInView(range: ICellRange): void;
scrollToBottom(): void;
revealCell(cell: ICellViewModel, revealType: CellRevealSyncType): void;
revealCellAsync(cell: ICellViewModel, revealType: CellRevealType): Promise<void>;
revealCellRangeAsync(cell: ICellViewModel, range: Selection | Range, revealType: CellRevealRangeType): Promise<void>;
revealCellOffsetInCenterAsync(element: ICellViewModel, offset: number): Promise<void>;
revealCell(cell: ICellViewModel, revealType: CellRevealType): void;
revealCells(range: ICellRange): void;
revealRangeInCell(cell: ICellViewModel, range: Selection | Range, revealType: CellRevealRangeType): Promise<void>;
revealCellOffsetInCenter(element: ICellViewModel, offset: number): void;
setHiddenAreas(_ranges: ICellRange[], triggerViewUpdate: boolean): boolean;
domElementOfElement(element: ICellViewModel): HTMLElement | null;
focusView(): void;
@@ -65,17 +65,17 @@ suite('NotebookCellList', () => {
assert.deepStrictEqual(cellList.getViewScrollBottom(), 215);
// reveal cell 1, top 50, bottom 150, which is fully visible in the viewport
cellList.revealCellsInView({ start: 1, end: 2 });
cellList.revealCells({ start: 1, end: 2 });
assert.deepStrictEqual(cellList.scrollTop, 5);
assert.deepStrictEqual(cellList.getViewScrollBottom(), 215);
// reveal cell 2, top 150, bottom 200, which is fully visible in the viewport
cellList.revealCellsInView({ start: 2, end: 3 });
cellList.revealCells({ start: 2, end: 3 });
assert.deepStrictEqual(cellList.scrollTop, 5);
assert.deepStrictEqual(cellList.getViewScrollBottom(), 215);
// reveal cell 3, top 200, bottom 300, which is partially visible in the viewport
cellList.revealCellsInView({ start: 3, end: 4 });
cellList.revealCells({ start: 3, end: 4 });
assert.deepStrictEqual(cellList.scrollTop, 90);
});
});
@@ -110,7 +110,7 @@ suite('NotebookCellList', () => {
assert.deepStrictEqual(cellList.getViewScrollBottom(), 210);
// reveal cell 3, top 200, bottom 300, which is partially visible in the viewport
cellList.revealCellsInView({ start: 3, end: 4 });
cellList.revealCells({ start: 3, end: 4 });
assert.deepStrictEqual(cellList.scrollTop, 90);
// scroll to 5
@@ -119,7 +119,7 @@ suite('NotebookCellList', () => {
assert.deepStrictEqual(cellList.getViewScrollBottom(), 215);
// reveal cell 0, top 0, bottom 50
cellList.revealCellsInView({ start: 0, end: 1 });
cellList.revealCells({ start: 0, end: 1 });
assert.deepStrictEqual(cellList.scrollTop, 0);
});
});
@@ -155,7 +155,7 @@ suite('NotebookCellList', () => {
assert.deepStrictEqual(cellList.scrollTop, 0);
assert.deepStrictEqual(cellList.getViewScrollBottom(), 210);
cellList.revealCellsInView({ start: 4, end: 5 });
cellList.revealCells({ start: 4, end: 5 });
assert.deepStrictEqual(cellList.scrollTop, 140);
// assert.deepStrictEqual(cellList.getViewScrollBottom(), 330);
});
@@ -23,7 +23,7 @@ function getCount(repository: ISCMRepository): number {
if (typeof repository.provider.count === 'number') {
return repository.provider.count;
} else {
return repository.provider.groups.elements.reduce<number>((r, g) => r + g.elements.length, 0);
return repository.provider.groups.reduce<number>((r, g) => r + g.resources.length, 0);
}
}
@@ -264,8 +264,8 @@ export class SCMActiveResourceContextKeyController implements IWorkbenchContribu
this.activeResourceRepositoryContextKey.set(activeResourceRepository?.id);
for (const resourceGroup of activeResourceRepository?.provider.groups.elements ?? []) {
if (resourceGroup.elements
for (const resourceGroup of activeResourceRepository?.provider.groups ?? []) {
if (resourceGroup.resources
.some(scmResource =>
this.uriIdentityService.extUri.isEqual(activeResource, scmResource.sourceUri))) {
this.activeResourceHasChangesContextKey.set(true);
+9 -12
View File
@@ -12,7 +12,6 @@ import { IAction } from 'vs/base/common/actions';
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { ISCMResource, ISCMResourceGroup, ISCMProvider, ISCMRepository, ISCMService, ISCMMenus, ISCMRepositoryMenus } from 'vs/workbench/contrib/scm/common/scm';
import { equals } from 'vs/base/common/arrays';
import { ISplice } from 'vs/base/common/sequence';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { localize } from 'vs/nls';
@@ -148,7 +147,6 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
private contextKeyService: IContextKeyService;
readonly titleMenu: SCMTitleMenu;
private readonly resourceGroups: ISCMResourceGroup[] = [];
private readonly resourceGroupMenusItems = new Map<ISCMResourceGroup, SCMMenusItem>();
private _repositoryMenu: IMenu | undefined;
@@ -164,7 +162,7 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
private readonly disposables = new DisposableStore();
constructor(
provider: ISCMProvider,
private readonly provider: ISCMProvider,
@IContextKeyService contextKeyService: IContextKeyService,
@IInstantiationService instantiationService: IInstantiationService,
@IMenuService private readonly menuService: IMenuService
@@ -179,8 +177,8 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
instantiationService = instantiationService.createChild(serviceCollection);
this.titleMenu = instantiationService.createInstance(SCMTitleMenu);
provider.groups.onDidSplice(this.onDidSpliceGroups, this, this.disposables);
this.onDidSpliceGroups({ start: 0, deleteCount: 0, toInsert: provider.groups.elements });
provider.onDidChangeResourceGroups(this.onDidChangeResourceGroups, this, this.disposables);
this.onDidChangeResourceGroups();
}
getResourceGroupMenu(group: ISCMResourceGroup): IMenu {
@@ -210,13 +208,12 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
return result;
}
private onDidSpliceGroups({ start, deleteCount, toInsert }: ISplice<ISCMResourceGroup>): void {
const deleted = this.resourceGroups.splice(start, deleteCount, ...toInsert);
for (const group of deleted) {
const item = this.resourceGroupMenusItems.get(group);
item?.dispose();
this.resourceGroupMenusItems.delete(group);
private onDidChangeResourceGroups(): void {
for (const resourceGroup of this.resourceGroupMenusItems.keys()) {
if (!this.provider.groups.includes(resourceGroup)) {
this.resourceGroupMenusItems.get(resourceGroup)?.dispose();
this.resourceGroupMenusItems.delete(resourceGroup);
}
}
}
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ISCMResource, ISCMRepository, ISCMResourceGroup, ISCMInput, ISCMActionButton } from 'vs/workbench/contrib/scm/common/scm';
import { ISCMResource, ISCMRepository, ISCMResourceGroup, ISCMInput, ISCMActionButton, ISCMViewService } from 'vs/workbench/contrib/scm/common/scm';
import { IMenu } from 'vs/platform/actions/common/actions';
import { ActionBar, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDisposable } from 'vs/base/common/lifecycle';
@@ -21,6 +21,10 @@ export function isSCMRepositoryArray(element: any): element is ISCMRepository[]
return Array.isArray(element) && element.every(r => isSCMRepository(r));
}
export function isSCMViewService(element: any): element is ISCMViewService {
return Array.isArray((element as ISCMViewService).repositories) && Array.isArray((element as ISCMViewService).visibleRepositories);
}
export function isSCMRepository(element: any): element is ISCMRepository {
return !!(element as ISCMRepository).provider && !!(element as ISCMRepository).input;
}
@@ -34,7 +38,7 @@ export function isSCMActionButton(element: any): element is ISCMActionButton {
}
export function isSCMResourceGroup(element: any): element is ISCMResourceGroup {
return !!(element as ISCMResourceGroup).provider && !!(element as ISCMResourceGroup).elements;
return !!(element as ISCMResourceGroup).provider && !!(element as ISCMResourceGroup).resources;
}
export function isSCMResource(element: any): element is ISCMResource {
+12 -8
View File
@@ -8,11 +8,11 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import { Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Command } from 'vs/editor/common/languages';
import { ISequence } from 'vs/base/common/sequence';
import { IAction } from 'vs/base/common/actions';
import { IMenu } from 'vs/platform/actions/common/actions';
import { ThemeIcon } from 'vs/base/common/themables';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { ResourceTree } from 'vs/base/common/resourceTree';
import { ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
export const VIEWLET_ID = 'workbench.view.scm';
@@ -43,22 +43,26 @@ export interface ISCMResource {
open(preserveFocus: boolean): Promise<void>;
}
export interface ISCMResourceGroup extends ISequence<ISCMResource> {
readonly provider: ISCMProvider;
readonly label: string;
export interface ISCMResourceGroup {
readonly id: string;
readonly provider: ISCMProvider;
readonly resources: readonly ISCMResource[];
readonly resourceTree: ResourceTree<ISCMResource, ISCMResourceGroup>;
readonly onDidChangeResources: Event<void>;
readonly label: string;
readonly hideWhenEmpty: boolean;
readonly onDidChange: Event<void>;
}
export interface ISCMProvider extends IDisposable {
readonly label: string;
readonly id: string;
readonly label: string;
readonly contextValue: string;
readonly groups: ISequence<ISCMResourceGroup>;
// TODO@Joao: remove
readonly groups: readonly ISCMResourceGroup[];
readonly onDidChangeResourceGroups: Event<void>;
readonly onDidChangeResources: Event<void>;
readonly rootUri?: URI;
@@ -907,7 +907,7 @@ export class FileMatch extends Disposable implements IFileMatch {
if (match.webviewIndex !== undefined) {
const index = this._notebookEditorWidget.getCellIndex(match.cell);
if (index !== undefined) {
this._notebookEditorWidget.revealCellOffsetInCenterAsync(match.cell, outputOffset ?? 0);
this._notebookEditorWidget.revealCellOffsetInCenter(match.cell, outputOffset ?? 0);
}
} else {
match.cell.updateEditState(match.cell.getEditState(), 'focusNotebookCell');
@@ -194,6 +194,7 @@ const PyModulesToLookFor = [
'azure-ai-ml',
'azure-ai-translation-document',
'azure-appconfiguration',
'azure-appconfiguration-provider',
'azure-loganalytics',
'azure-synapse-nspkg',
'azure-synapse-spark',
@@ -205,7 +206,19 @@ const PyModulesToLookFor = [
'azure-cognitiveservices-nspkg',
'azure-cognitiveservices-language-nspkg',
'azure-cognitiveservices-knowledge-nspkg',
'azure-communication-identity',
'azure-communication-phonenumbers',
'azure-communication-email',
'azure-communication-rooms',
'azure-communication-callautomation',
'azure-confidentialledger',
'azure-containerregistry',
'azure-developer-loadtesting',
'azure-iot-deviceupdate',
'azure-messaging-webpubsubservice',
'azure-monitor',
'azure-monitor-query',
'azure-monitor-ingestion',
'azure-mgmt-appcontainers',
'azure-mgmt-apimanagement',
'azure-mgmt-web',
@@ -254,6 +267,7 @@ const PyModulesToLookFor = [
'azure-ai-nspkg',
'azure-cognitiveservices-language-textanalytics',
'azure-ai-textanalytics',
'azure-schemaregistry-avroencoder',
'azure-schemaregistry-avroserializer',
'azure-schemaregistry',
'azure-eventhub-checkpointstoreblob-aio',
@@ -630,6 +644,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
"workspace.py.azure-cognitiveservices-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-cognitiveservices-language-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-cognitiveservices-knowledge-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-containerregistry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-ai-metricsadvisor" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azureml-sdk" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-keyvault-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
@@ -672,6 +687,19 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
"workspace.py.azure-communication-chat" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-administration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-security-attestation" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-appconfiguration-provider" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-identity" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-phonenumbers" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-email" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-rooms" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-communication-callautomation" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-confidentialledger" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-iot-deviceupdate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-developer-loadtesting" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-monitor-query" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-monitor-ingestion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-schemaregistry-avroencoder" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-messaging-webpubsubservice" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-data-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.azure-data-tables" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"workspace.py.transformers" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
@@ -123,7 +123,6 @@
code {
font-family: var(--monaco-monospace-font);
color: var(--vscode-textPreformat-foreground);
font-size: 12px;
background-color: var(--vscode-textPreformat-background);
padding: 1px 3px;
border-radius: 4px;
@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'sha256-Ne5nVg2ZDLxLh1eqzYd1sGbOz022xlokwv+X6+HR1hw=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
content="default-src 'none'; script-src 'sha256-frEVWVmmI4TWHGHXZaCTWqGQI9jv+i8hv+sOa87Gqlc=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
<!-- Disable pinch zooming -->
<meta name="viewport"
@@ -124,7 +124,6 @@
code {
font-family: var(--monaco-monospace-font);
color: var(--vscode-textPreformat-foreground);
font-size: 12px;
background-color: var(--vscode-textPreformat-background);
padding: 1px 3px;
border-radius: 4px;
@@ -68,13 +68,21 @@ class QuickInputHoverDelegate implements IHoverDelegate {
) { }
showHover(options: IHoverDelegateOptions, focus?: boolean): IHoverWidget | undefined {
// Only show the hover hint if the content is of a decent size
const showHoverHint = (
options.content instanceof HTMLElement
? options.content.textContent ?? ''
: typeof options.content === 'string'
? options.content
: options.content.value
).length > 20;
return this.hoverService.showHover({
...options,
persistence: {
hideOnKeyDown: false,
},
appearance: {
showHoverHint: true,
showHoverHint,
skipFadeInAnimation: true,
},
}, focus);