Skip to content

Commit 27eb6df

Browse files
committed
Merge remote-tracking branch 'origin/main' into alexd/spiritual-bug
2 parents 7a5cdf4 + 1a2cc56 commit 27eb6df

File tree

25 files changed

+223
-150
lines changed

25 files changed

+223
-150
lines changed

extensions/git/src/decorationProvider.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as path from 'path';
88
import { Repository, GitResourceGroup } from './repository';
99
import { Model } from './model';
1010
import { debounce } from './decorators';
11-
import { filterEvent, dispose, anyEvent, fireEvent, PromiseSource, combinedDisposable } from './util';
11+
import { filterEvent, dispose, anyEvent, fireEvent, PromiseSource, combinedDisposable, runAndSubscribeEvent } from './util';
1212
import { Change, GitErrorCodes, Status } from './api/git';
1313

1414
class GitIgnoreDecorationProvider implements FileDecorationProvider {
@@ -101,7 +101,7 @@ class GitDecorationProvider implements FileDecorationProvider {
101101
constructor(private repository: Repository) {
102102
this.disposables.push(
103103
window.registerFileDecorationProvider(this),
104-
repository.onDidRunGitStatus(this.onDidRunGitStatus, this)
104+
runAndSubscribeEvent(repository.onDidRunGitStatus, () => this.onDidRunGitStatus())
105105
);
106106
}
107107

@@ -162,8 +162,10 @@ class GitIncomingChangesFileDecorationProvider implements FileDecorationProvider
162162
private readonly disposables: Disposable[] = [];
163163

164164
constructor(private readonly repository: Repository) {
165-
this.disposables.push(window.registerFileDecorationProvider(this));
166-
repository.historyProvider.onDidChangeCurrentHistoryItemGroup(this.onDidChangeCurrentHistoryItemGroup, this, this.disposables);
165+
this.disposables.push(
166+
window.registerFileDecorationProvider(this),
167+
runAndSubscribeEvent(repository.historyProvider.onDidChangeCurrentHistoryItemGroup, () => this.onDidChangeCurrentHistoryItemGroup())
168+
);
167169
}
168170

169171
private async onDidChangeCurrentHistoryItemGroup(): Promise<void> {

extensions/git/src/util.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ export function filterEvent<T>(event: Event<T>, filter: (e: T) => boolean): Even
4747
return (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) => event(e => filter(e) && listener.call(thisArgs, e), null, disposables);
4848
}
4949

50+
export function runAndSubscribeEvent<T>(event: Event<T>, handler: (e: T) => any, initial: T): IDisposable;
51+
export function runAndSubscribeEvent<T>(event: Event<T>, handler: (e: T | undefined) => any): IDisposable;
52+
export function runAndSubscribeEvent<T>(event: Event<T>, handler: (e: T | undefined) => any, initial?: T): IDisposable {
53+
handler(initial);
54+
return event(e => handler(e));
55+
}
56+
5057
export function anyEvent<T>(...events: Event<T>[]): Event<T> {
5158
return (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) => {
5259
const result = combinedDisposable(events.map(event => event(i => listener.call(thisArgs, i))));

src/vs/base/browser/ui/menu/menu.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ export const MENU_ESCAPED_MNEMONIC_REGEX = /(&amp;)?(&amp;)([^\s&])/g;
3131

3232

3333

34-
export enum Direction {
34+
export enum HorizontalDirection {
3535
Right,
3636
Left
3737
}
3838

39+
export enum VerticalDirection {
40+
Above,
41+
Below
42+
}
43+
44+
export interface IMenuDirection {
45+
horizontal: HorizontalDirection;
46+
vertical: VerticalDirection;
47+
}
48+
3949
export interface IMenuOptions {
4050
context?: unknown;
4151
actionViewItemProvider?: IActionViewItemProvider;
@@ -44,7 +54,7 @@ export interface IMenuOptions {
4454
ariaLabel?: string;
4555
enableMnemonics?: boolean;
4656
anchorAlignment?: AnchorAlignment;
47-
expandDirection?: Direction;
57+
expandDirection?: IMenuDirection;
4858
useEventAsContext?: boolean;
4959
submenuIds?: Set<string>;
5060
}
@@ -725,7 +735,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
725735
private mouseOver: boolean = false;
726736
private showScheduler: RunOnceScheduler;
727737
private hideScheduler: RunOnceScheduler;
728-
private expandDirection: Direction;
738+
private expandDirection: IMenuDirection;
729739

730740
constructor(
731741
action: IAction,
@@ -736,7 +746,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
736746
) {
737747
super(action, action, submenuOptions, menuStyles);
738748

739-
this.expandDirection = submenuOptions && submenuOptions.expandDirection !== undefined ? submenuOptions.expandDirection : Direction.Right;
749+
this.expandDirection = submenuOptions && submenuOptions.expandDirection !== undefined ? submenuOptions.expandDirection : { horizontal: HorizontalDirection.Right, vertical: VerticalDirection.Below };
740750

741751
this.showScheduler = new RunOnceScheduler(() => {
742752
if (this.mouseOver) {
@@ -850,11 +860,11 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
850860
}
851861
}
852862

853-
private calculateSubmenuMenuLayout(windowDimensions: Dimension, submenu: Dimension, entry: IDomNodePagePosition, expandDirection: Direction): { top: number; left: number } {
863+
private calculateSubmenuMenuLayout(windowDimensions: Dimension, submenu: Dimension, entry: IDomNodePagePosition, expandDirection: IMenuDirection): { top: number; left: number } {
854864
const ret = { top: 0, left: 0 };
855865

856866
// Start with horizontal
857-
ret.left = layout(windowDimensions.width, submenu.width, { position: expandDirection === Direction.Right ? LayoutAnchorPosition.Before : LayoutAnchorPosition.After, offset: entry.left, size: entry.width });
867+
ret.left = layout(windowDimensions.width, submenu.width, { position: expandDirection.horizontal === HorizontalDirection.Right ? LayoutAnchorPosition.Before : LayoutAnchorPosition.After, offset: entry.left, size: entry.width });
858868

859869
// We don't have enough room to layout the menu fully, so we are overlapping the menu
860870
if (ret.left >= entry.left && ret.left < entry.left + entry.width) {

src/vs/base/browser/ui/menu/menubar.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as DOM from 'vs/base/browser/dom';
88
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
99
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
1010
import { EventType, Gesture, GestureEvent } from 'vs/base/browser/touch';
11-
import { cleanMnemonic, Direction, IMenuOptions, IMenuStyles, Menu, MENU_ESCAPED_MNEMONIC_REGEX, MENU_MNEMONIC_REGEX } from 'vs/base/browser/ui/menu/menu';
11+
import { cleanMnemonic, HorizontalDirection, IMenuDirection, IMenuOptions, IMenuStyles, Menu, MENU_ESCAPED_MNEMONIC_REGEX, MENU_MNEMONIC_REGEX, VerticalDirection } from 'vs/base/browser/ui/menu/menu';
1212
import { ActionRunner, IAction, IActionRunner, Separator, SubmenuAction } from 'vs/base/common/actions';
1313
import { asArray } from 'vs/base/common/arrays';
1414
import { RunOnceScheduler } from 'vs/base/common/async';
@@ -32,7 +32,7 @@ export interface IMenuBarOptions {
3232
visibility?: string;
3333
getKeybinding?: (action: IAction) => ResolvedKeybinding | undefined;
3434
alwaysOnMnemonics?: boolean;
35-
compactMode?: Direction;
35+
compactMode?: IMenuDirection;
3636
actionRunner?: IActionRunner;
3737
getCompactMenuActions?: () => IAction[];
3838
}
@@ -333,9 +333,9 @@ export class MenuBar extends Disposable {
333333
} else {
334334
triggerKeys.push(KeyCode.Space);
335335

336-
if (this.options.compactMode === Direction.Right) {
336+
if (this.options.compactMode?.horizontal === HorizontalDirection.Right) {
337337
triggerKeys.push(KeyCode.RightArrow);
338-
} else if (this.options.compactMode === Direction.Left) {
338+
} else if (this.options.compactMode?.horizontal === HorizontalDirection.Left) {
339339
triggerKeys.push(KeyCode.LeftArrow);
340340
}
341341
}
@@ -1007,26 +1007,33 @@ export class MenuBar extends Disposable {
10071007
const titleBoundingRect = customMenu.titleElement.getBoundingClientRect();
10081008
const titleBoundingRectZoom = DOM.getDomNodeZoomLevel(customMenu.titleElement);
10091009

1010-
if (this.options.compactMode === Direction.Right) {
1011-
menuHolder.style.top = `${titleBoundingRect.top}px`;
1010+
if (this.options.compactMode?.horizontal === HorizontalDirection.Right) {
10121011
menuHolder.style.left = `${titleBoundingRect.left + this.container.clientWidth}px`;
1013-
} else if (this.options.compactMode === Direction.Left) {
1012+
} else if (this.options.compactMode?.horizontal === HorizontalDirection.Left) {
10141013
menuHolder.style.top = `${titleBoundingRect.top}px`;
10151014
menuHolder.style.right = `${this.container.clientWidth}px`;
10161015
menuHolder.style.left = 'auto';
10171016
} else {
1018-
menuHolder.style.top = `${titleBoundingRect.bottom * titleBoundingRectZoom}px`;
10191017
menuHolder.style.left = `${titleBoundingRect.left * titleBoundingRectZoom}px`;
10201018
}
10211019

1020+
if (this.options.compactMode?.vertical === VerticalDirection.Above) {
1021+
// TODO@benibenj Do not hardcode the height of the menu holder
1022+
menuHolder.style.top = `${titleBoundingRect.top - this.menus.length * 30 + this.container.clientHeight}px`;
1023+
} else if (this.options.compactMode?.vertical === VerticalDirection.Below) {
1024+
menuHolder.style.top = `${titleBoundingRect.top}px`;
1025+
} else {
1026+
menuHolder.style.top = `${titleBoundingRect.bottom * titleBoundingRectZoom}px`;
1027+
}
1028+
10221029
customMenu.buttonElement.appendChild(menuHolder);
10231030

10241031
const menuOptions: IMenuOptions = {
10251032
getKeyBinding: this.options.getKeybinding,
10261033
actionRunner: this.actionRunner,
10271034
enableMnemonics: this.options.alwaysOnMnemonics || (this.mnemonicsInUse && this.options.enableMnemonics),
10281035
ariaLabel: customMenu.buttonElement.getAttribute('aria-label') ?? undefined,
1029-
expandDirection: this.isCompact ? this.options.compactMode : Direction.Right,
1036+
expandDirection: this.isCompact ? this.options.compactMode : { horizontal: HorizontalDirection.Right, vertical: VerticalDirection.Below },
10301037
useEventAsContext: true
10311038
};
10321039

src/vs/editor/browser/widget/diffEditor/features/gutterFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class DiffEditorGutter extends Disposable {
8484
const currentDiff = this._currentDiff.read(reader);
8585

8686
return diffs.mappings.map(m => new DiffGutterItem(
87-
m.lineRangeMapping,
87+
m.lineRangeMapping.withInnerChangesFromLineRanges(),
8888
m.lineRangeMapping === currentDiff?.lineRangeMapping,
8989
MenuId.DiffEditorHunkToolbar,
9090
undefined,

src/vs/editor/common/diff/rangeMapping.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ export class DetailedLineRangeMapping extends LineRangeMapping {
118118
public override flip(): DetailedLineRangeMapping {
119119
return new DetailedLineRangeMapping(this.modified, this.original, this.innerChanges?.map(c => c.flip()));
120120
}
121+
122+
public withInnerChangesFromLineRanges(): DetailedLineRangeMapping {
123+
return new DetailedLineRangeMapping(this.original, this.modified, [
124+
new RangeMapping(this.original.toExclusiveRange(), this.modified.toExclusiveRange()),
125+
]);
126+
}
121127
}
122128

123129
/**

src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
1414
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
1515
import { IThemeService } from 'vs/platform/theme/common/themeService';
1616
import { ActiveAuxiliaryContext, AuxiliaryBarFocusContext } from 'vs/workbench/common/contextkeys';
17-
import { ACTIVITY_BAR_BADGE_BACKGROUND, ACTIVITY_BAR_BADGE_FOREGROUND, PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_DRAG_AND_DROP_BORDER, PANEL_INACTIVE_TITLE_FOREGROUND, SIDE_BAR_BACKGROUND, SIDE_BAR_BORDER, SIDE_BAR_FOREGROUND } from 'vs/workbench/common/theme';
17+
import { ACTIVITY_BAR_BADGE_BACKGROUND, ACTIVITY_BAR_BADGE_FOREGROUND, ACTIVITY_BAR_TOP_ACTIVE_BORDER, ACTIVITY_BAR_TOP_DRAG_AND_DROP_BORDER, ACTIVITY_BAR_TOP_FOREGROUND, ACTIVITY_BAR_TOP_INACTIVE_FOREGROUND, PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_DRAG_AND_DROP_BORDER, PANEL_INACTIVE_TITLE_FOREGROUND, SIDE_BAR_BACKGROUND, SIDE_BAR_BORDER, SIDE_BAR_FOREGROUND } from 'vs/workbench/common/theme';
1818
import { IViewDescriptorService } from 'vs/workbench/common/views';
1919
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
2020
import { ActivityBarPosition, IWorkbenchLayoutService, LayoutSettings, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
@@ -169,12 +169,12 @@ export class AuxiliaryBarPart extends AbstractPaneCompositePart {
169169
colors: theme => ({
170170
activeBackgroundColor: theme.getColor(SIDE_BAR_BACKGROUND),
171171
inactiveBackgroundColor: theme.getColor(SIDE_BAR_BACKGROUND),
172-
activeBorderBottomColor: theme.getColor(PANEL_ACTIVE_TITLE_BORDER),
173-
activeForegroundColor: theme.getColor(PANEL_ACTIVE_TITLE_FOREGROUND),
174-
inactiveForegroundColor: theme.getColor(PANEL_INACTIVE_TITLE_FOREGROUND),
172+
get activeBorderBottomColor() { return $this.getCompositeBarPosition() === CompositeBarPosition.TITLE ? theme.getColor(PANEL_ACTIVE_TITLE_BORDER) : theme.getColor(ACTIVITY_BAR_TOP_ACTIVE_BORDER); },
173+
get activeForegroundColor() { return $this.getCompositeBarPosition() === CompositeBarPosition.TITLE ? theme.getColor(PANEL_ACTIVE_TITLE_FOREGROUND) : theme.getColor(ACTIVITY_BAR_TOP_FOREGROUND); },
174+
get inactiveForegroundColor() { return $this.getCompositeBarPosition() === CompositeBarPosition.TITLE ? theme.getColor(PANEL_INACTIVE_TITLE_FOREGROUND) : theme.getColor(ACTIVITY_BAR_TOP_INACTIVE_FOREGROUND); },
175175
badgeBackground: theme.getColor(ACTIVITY_BAR_BADGE_BACKGROUND),
176176
badgeForeground: theme.getColor(ACTIVITY_BAR_BADGE_FOREGROUND),
177-
dragAndDropBorder: theme.getColor(PANEL_DRAG_AND_DROP_BORDER)
177+
get dragAndDropBorder() { return $this.getCompositeBarPosition() === CompositeBarPosition.TITLE ? theme.getColor(PANEL_DRAG_AND_DROP_BORDER) : theme.getColor(ACTIVITY_BAR_TOP_DRAG_AND_DROP_BORDER); }
178178
}),
179179
compact: true
180180
};
@@ -205,6 +205,7 @@ export class AuxiliaryBarPart extends AbstractPaneCompositePart {
205205
return this.configurationService.getValue<ActivityBarPosition>(LayoutSettings.ACTIVITY_BAR_LOCATION) !== ActivityBarPosition.HIDDEN;
206206
}
207207

208+
// TODO@benibenj chache this
208209
protected getCompositeBarPosition(): CompositeBarPosition {
209210
const activityBarPosition = this.configurationService.getValue<ActivityBarPosition>(LayoutSettings.ACTIVITY_BAR_LOCATION);
210211
switch (activityBarPosition) {

src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,26 @@
5151
left: 6px; /* place icon in center */
5252
}
5353

54-
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked:not(:focus) .active-item-indicator:before,
55-
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked.clicked:focus .active-item-indicator:before,
5654
.monaco-workbench .part.auxiliarybar > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked:not(:focus) .active-item-indicator:before,
5755
.monaco-workbench .part.auxiliarybar > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked.clicked:focus .active-item-indicator:before {
56+
border-top-color: var(--vscode-panelTitle-activeBorder) !important;
57+
}
58+
59+
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked:not(:focus) .active-item-indicator:before,
60+
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked.clicked:focus .active-item-indicator:before {
5861
border-top-color: var(--vscode-activityBarTop-activeBorder) !important;
5962
}
6063

61-
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:hover .action-label,
62-
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:focus .action-label,
6364
.monaco-workbench .part.auxiliarybar > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:hover .action-label,
6465
.monaco-workbench .part.auxiliarybar > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:focus .action-label {
6566
color: var(--vscode-sideBarTitle-foreground) !important;
6667
}
6768

69+
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:hover .action-label,
70+
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:focus .action-label {
71+
color: var(--vscode-activityBarTop-foreground) !important;
72+
}
73+
6874
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked .action-label,
6975
.monaco-workbench .part.auxiliarybar > .header-or-footer > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item:hover .action-label,
7076
.monaco-workbench .part.auxiliarybar > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.checked .action-label,

src/vs/workbench/browser/parts/titlebar/menubarControl.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
2525
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
2626
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
2727
import { MenuBar, IMenuBarOptions } from 'vs/base/browser/ui/menu/menubar';
28-
import { Direction } from 'vs/base/browser/ui/menu/menu';
28+
import { HorizontalDirection, IMenuDirection, VerticalDirection } from 'vs/base/browser/ui/menu/menu';
2929
import { mnemonicMenuLabel, unmnemonicLabel } from 'vs/base/common/labels';
3030
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
3131
import { isFullscreen, onDidChangeFullscreen } from 'vs/base/browser/browser';
@@ -41,6 +41,7 @@ import { isICommandActionToggleInfo } from 'vs/platform/action/common/action';
4141
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
4242
import { defaultMenuStyles } from 'vs/platform/theme/browser/defaultStyles';
4343
import { mainWindow } from 'vs/base/browser/window';
44+
import { ActivityBarPosition } from 'vs/workbench/services/layout/browser/layoutService';
4445

4546
export type IOpenRecentAction = IAction & { uri: URI; remoteAuthority?: string };
4647

@@ -536,14 +537,19 @@ export class CustomMenubarControl extends MenubarControl {
536537
return enableMenuBarMnemonics && (!isWeb || isFullscreen(mainWindow));
537538
}
538539

539-
private get currentCompactMenuMode(): Direction | undefined {
540+
private get currentCompactMenuMode(): IMenuDirection | undefined {
540541
if (this.currentMenubarVisibility !== 'compact') {
541542
return undefined;
542543
}
543544

544545
// Menu bar lives in activity bar and should flow based on its location
545546
const currentSidebarLocation = this.configurationService.getValue<string>('workbench.sideBar.location');
546-
return currentSidebarLocation === 'right' ? Direction.Left : Direction.Right;
547+
const horizontalDirection = currentSidebarLocation === 'right' ? HorizontalDirection.Left : HorizontalDirection.Right;
548+
549+
const activityBarLocation = this.configurationService.getValue<string>('workbench.activityBar.location');
550+
const verticalDirection = activityBarLocation === ActivityBarPosition.BOTTOM ? VerticalDirection.Above : VerticalDirection.Below;
551+
552+
return { horizontal: horizontalDirection, vertical: verticalDirection };
547553
}
548554

549555
private onDidVisibilityChange(visible: boolean): void {

0 commit comments

Comments
 (0)