Skip to content

Commit

Permalink
add stuff for widget status
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Jan 22, 2025
1 parent 9d62bcd commit 478d09d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/vs/editor/contrib/suggest/browser/suggestWidgetStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export class SuggestWidgetStatus {
@IContextKeyService private _contextKeyService: IContextKeyService,
) {
this.element = dom.append(container, dom.$('.suggest-status-bar'));
console.log('SuggestWidgetStatus element', this.element);
console.log('SuggestWidgetStatus container', container);

const actionViewItemProvider = <IActionViewItemProvider>(action => {
return action instanceof MenuItemAction ? instantiationService.createInstance(TextOnlyMenuEntryActionViewItem, action, { useComma: true }) : undefined;
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class MenuId {
static readonly MenubarSwitchEditorMenu = new MenuId('MenubarSwitchEditorMenu');
static readonly MenubarSwitchGroupMenu = new MenuId('MenubarSwitchGroupMenu');
static readonly MenubarTerminalMenu = new MenuId('MenubarTerminalMenu');
static readonly MenubarTerminalSuggestStatusMenu = new MenuId('MenubarTerminalSuggestStatusMenu');
static readonly MenubarViewMenu = new MenuId('MenubarViewMenu');
static readonly MenubarHomeMenu = new MenuId('MenubarHomeMenu');
static readonly OpenEditorsContext = new MenuId('OpenEditorsContext');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { PwshCompletionProviderAddon } from './pwshCompletionProviderAddon.js';
import { SimpleSuggestContext } from '../../../../services/suggest/browser/simpleSuggestWidget.js';
import { SuggestDetailsClassName } from '../../../../services/suggest/browser/simpleSuggestWidgetDetails.js';
import { EditorContextKeys } from '../../../../../editor/common/editorContextKeys.js';
import { MenuId } from '../../../../../platform/actions/common/actions.js';

registerSingleton(ITerminalCompletionService, TerminalCompletionService, InstantiationType.Delayed);

Expand Down Expand Up @@ -326,6 +327,9 @@ registerActiveInstanceAction({
// Tab is bound to other workbench keybindings that this needs to beat
weight: KeybindingWeight.WorkbenchContrib + 1
},
menu: {
id: MenuId.MenubarTerminalSuggestStatusMenu
},
run: (activeInstance) => TerminalSuggestContribution.get(activeInstance)?.addon?.acceptSelectedSuggestion()
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { TerminalShellType } from '../../../../../platform/terminal/common/termi
import { CancellationToken, CancellationTokenSource } from '../../../../../base/common/cancellation.js';
import { IExtensionService } from '../../../../services/extensions/common/extensions.js';
import { ThemeIcon } from '../../../../../base/common/themables.js';
import { MenuId } from '../../../../../platform/actions/common/actions.js';

export interface ISuggestController {
isPasting: boolean;
Expand Down Expand Up @@ -408,7 +409,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
this._container!,
this._instantiationService.createInstance(PersistedWidgetSize),
() => fontInfo,
{}
{ statusBarMenuId: MenuId.MenubarTerminalSuggestStatusMenu },
));
this._suggestWidget.list.style(getListStyles({
listInactiveFocusBackground: editorSuggestWidgetSelectedBackground,
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/services/suggest/browser/media/suggest.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
display: flex;
}

.monaco-workbench .workbench-suggest-widget .suggest-status-bar {
box-sizing: border-box;
display: none;
flex-flow: row nowrap;
justify-content: space-between;
width: 100%;
font-size: 80%;
padding: 0 4px 0 4px;
border-top: 1px solid var(--vscode-editorSuggestWidget-border);
overflow: hidden;
}

.monaco-workbench .workbench-suggest-widget .suggest-status-bar .left {
padding-right: 8px;
}
Expand Down
28 changes: 16 additions & 12 deletions src/vs/workbench/services/suggest/browser/simpleSuggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class SimpleSuggestWidget extends Disposable {
private readonly _container: HTMLElement,
private readonly _persistedSize: IPersistedWidgetSizeDelegate,
private readonly _getFontInfo: () => ISimpleSuggestWidgetFontInfo,
options: IWorkbenchSuggestWidgetOptions,
private readonly _options: IWorkbenchSuggestWidgetOptions,
@IInstantiationService instantiationService: IInstantiationService,
@IConfigurationService configurationService: IConfigurationService,
@IStorageService private readonly _storageService: IStorageService,
Expand Down Expand Up @@ -227,9 +227,10 @@ export class SimpleSuggestWidget extends Disposable {
this._details = this._register(new SimpleSuggestDetailsOverlay(details, this._listElement));
this._register(dom.addDisposableListener(this._details.widget.domNode, 'blur', (e) => this._onDidBlurDetails.fire(e)));

if (options.statusBarMenuId) {
this._status = this._register(instantiationService.createInstance(SuggestWidgetStatus, this.element.domNode, options.statusBarMenuId));
if (_options.statusBarMenuId) {
this._status = this._register(instantiationService.createInstance(SuggestWidgetStatus, this.element.domNode, _options.statusBarMenuId));
this.element.domNode.classList.toggle('with-status-bar', true);
console.log(dom.$('.workbench-suggest-widget.with-status-bar').querySelector('.suggest-status-bar'));
}

this._register(this._list.onMouseDown(e => this._onListMouseDownOrTap(e)));
Expand Down Expand Up @@ -470,27 +471,30 @@ export class SimpleSuggestWidget extends Disposable {
break;
case State.Open:
dom.hide(this._messageElement);
dom.show(this._listElement);
if (this._status) {
dom.show(this._status?.element);
dom.show(this._listElement, this._status?.element);
} else {
dom.show(this._listElement);
}
this._show();
break;
case State.Frozen:
dom.hide(this._messageElement);
dom.show(this._listElement);
if (this._status) {
dom.show(this._status?.element);
dom.show(this._listElement, this._status?.element);
} else {
dom.show(this._listElement);
}
this._show();
break;
case State.Details:
dom.hide(this._messageElement);
dom.show(this._listElement);
if (this._status) {
dom.show(this._status?.element);
dom.show(this._listElement, this._status?.element);
} else {
dom.show(this._listElement);
}
// this._details.show();
this._details.show();
this._show();
break;
}
Expand Down Expand Up @@ -628,7 +632,7 @@ export class SimpleSuggestWidget extends Disposable {

// status bar
if (this._status) {
this._status.element.style.lineHeight = `${info.itemHeight}px`;
this._status.element.style.height = `${info.itemHeight}px`;
}

// if (this._state === State.Empty || this._state === State.Loading) {
Expand Down Expand Up @@ -749,7 +753,7 @@ export class SimpleSuggestWidget extends Disposable {
private _getLayoutInfo() {
const fontInfo = this._getFontInfo();
const itemHeight = clamp(Math.ceil(fontInfo.lineHeight), 8, 1000);
const statusBarHeight = 0; //!this.editor.getOption(EditorOption.suggest).showStatusBar || this._state === State.Empty || this._state === State.Loading ? 0 : itemHeight;
const statusBarHeight = !this._options.statusBarMenuId || this._state === State.Empty || this._state === State.Loading ? 0 : itemHeight;
const borderWidth = 1; //this._details.widget.borderWidth;
const borderHeight = 2 * borderWidth;

Expand Down

0 comments on commit 478d09d

Please sign in to comment.