Skip to content

Commit

Permalink
Editor Action Bar - Fix Preview in Quarto documents and Open in Viewe…
Browse files Browse the repository at this point in the history
…r in HTML documents (#5691)
  • Loading branch information
softwarenerd authored Dec 17, 2024
1 parent 135ec72 commit 74611ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { useEffect, useRef, useState } from 'react'; // eslint-disable-line no-d

// Other dependencies.
import { IAction } from '../../../../base/common/actions.js';
import { DisposableStore } from '../../../../base/common/lifecycle.js';
import { useStateRef } from '../../../../base/browser/ui/react/useStateRef.js';
import { MenuItemAction } from '../../../actions/common/actions.js';
import { IModifierKeyStatus, ModifierKeyEmitter } from '../../../../base/browser/dom.js';
import { IAccessibilityService } from '../../../accessibility/common/accessibility.js';
import { DisposableStore } from '../../../../base/common/lifecycle.js';
import { actionTooltip, toMenuActionItem } from '../../common/helpers.js';
import { useRegisterWithActionBar } from '../useRegisterWithActionBar.js';
import { usePositronActionBarContext } from '../positronActionBarContext.js';
import { ActionBarButton, ActionBarButtonProps } from './actionBarButton.js';
import { actionTooltip, toMenuActionItem } from '../../common/helpers.js';
import { useStateRef } from '../../../../base/browser/ui/react/useStateRef.js';
import { IAccessibilityService } from '../../../accessibility/common/accessibility.js';
import { IModifierKeyStatus, ModifierKeyEmitter } from '../../../../base/browser/dom.js';

/**
* Constants.
Expand Down Expand Up @@ -146,8 +146,13 @@ export const ActionBarActionButton = (props: ActionBarActionButtonProps) => {
disabled: !action.enabled,
onMouseEnter: () => setMouseInside(true),
onMouseLeave: () => setMouseInside(false),
onPressed: () =>
action.run()
onPressed: async () => {
try {
await action.run();
} catch (error) {
console.log(error);
}
}
};
})();

Expand Down
10 changes: 7 additions & 3 deletions src/vs/workbench/browser/parts/editor/editorActionBarFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import * as React from 'react';

// Other dependencies.
import { localize } from '../../../../nls.js';
import { IEditorGroupView } from './editor.js';
import { Emitter } from '../../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { IAction, Separator, SubmenuAction } from '../../../../base/common/actions.js';
import { IEditorGroupView } from './editor.js';
import { actionTooltip } from '../../../../platform/positronActionBar/common/helpers.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { PositronActionBar } from '../../../../platform/positronActionBar/browser/positronActionBar.js';
import { IMenu, IMenuService, MenuId, MenuItemAction } from '../../../../platform/actions/common/actions.js';
import { ActionBarRegion } from '../../../../platform/positronActionBar/browser/components/actionBarRegion.js';
import { ActionBarSeparator } from '../../../../platform/positronActionBar/browser/components/actionBarSeparator.js';
import { ActionBarMenuButton } from '../../../../platform/positronActionBar/browser/components/actionBarMenuButton.js';
import { ActionBarActionButton } from '../../../../platform/positronActionBar/browser/components/actionBarActionButton.js';
import { ActionBarCommandButton } from '../../../../platform/positronActionBar/browser/components/actionBarCommandButton.js';
import { IMenu, IMenuActionOptions, IMenuService, MenuId, MenuItemAction } from '../../../../platform/actions/common/actions.js';

// Constants.
const PADDING_LEFT = 8;
Expand Down Expand Up @@ -185,7 +185,11 @@ export class EditorActionBarFactory extends Disposable {
const primaryActions: IAction[] = [];
const secondaryActions: IAction[] = [];
const submenuDescriptors = new Set<SubmenuDescriptor>();
for (const [group, actions] of this._editorTitleMenu.getActions()) {
const options = {
arg: this._editorGroup.activeEditor?.resource,
shouldForwardArgs: true
} satisfies IMenuActionOptions;
for (const [group, actions] of this._editorTitleMenu.getActions(options)) {
// Determine the target actions.
const targetActions = this.isPrimaryGroup(group) ? primaryActions : secondaryActions;

Expand Down

0 comments on commit 74611ab

Please sign in to comment.