Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix updating items in the quick-pick menu #10055

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export interface QuickInputService {
Promise<(O extends { canPickMany: true } ? T[] : T) | undefined>;
showQuickPick<T extends QuickPickItem>(items: Array<T>, options?: QuickPickOptions<T>): Promise<T>;
hide(): void;
getCurrentInput(): QuickInput | undefined;
}

/**
Expand Down
25 changes: 21 additions & 4 deletions packages/monaco/src/browser/monaco-quick-input-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import {
InputBox, InputOptions, KeybindingRegistry, PickOptions,
QuickInputButton, QuickInputService, QuickPick, QuickPickItem, QuickPickItemButtonEvent, QuickPickItemHighlights, QuickPickOptions, QuickPickSeparator
InputBox,
InputOptions,
KeybindingRegistry,
PickOptions,
QuickInput,
QuickInputButton,
QuickInputService,
QuickPick,
QuickPickItem,
QuickPickItemButtonEvent,
QuickPickItemHighlights,
QuickPickOptions,
QuickPickSeparator
} from '@theia/core/lib/browser';
import { CancellationToken, Event } from '@theia/core/lib/common';
import { injectable, inject } from '@theia/core/shared/inversify';
Expand Down Expand Up @@ -162,6 +173,7 @@ export class MonacoQuickInputImplementation implements monaco.quickInput.IQuickI
export class MonacoQuickInputService implements QuickInputService {
@inject(MonacoQuickInputImplementation)
private monacoService: MonacoQuickInputImplementation;
private quickInput: QuickInput;

@inject(KeybindingRegistry)
protected readonly keybindingRegistry: KeybindingRegistry;
Expand Down Expand Up @@ -190,9 +202,10 @@ export class MonacoQuickInputService implements QuickInputService {
}

showQuickPick<T extends QuickPickItem>(items: T[], options?: QuickPickOptions<T>): Promise<T> {
const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>();
const wrapped = this.wrapQuickPick(quickPick);
this.quickInput = wrapped;
return new Promise<T>((resolve, reject) => {
const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>();
const wrapped = this.wrapQuickPick(quickPick);

if (options) {
wrapped.canSelectMany = !!options.canSelectMany;
Expand Down Expand Up @@ -272,6 +285,10 @@ export class MonacoQuickInputService implements QuickInputService {
hide(): void {
return this.monacoService.hide();
}

getCurrentInput(): QuickInput | undefined {
return this.quickInput;
}
}

class MonacoQuickInput {
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/main/browser/quick-open-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ export class QuickOpenMainImpl implements QuickOpenMain, Disposable {
matchOnLabel: true,
runIfSingle: false,
});
const input = this.quickInputService.getCurrentInput();
if (input) {
this.sessions.set(sessionId, { input, handlesToItems: new Map() });
}
}

$hide(): void {
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/plugin/quick-open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ export class QuickPickExt<T extends theia.QuickPickItem> extends QuickInputExt i
this._handlesToItems.set(i, item);
this._itemsToHandles.set(item, i);
});
items.forEach((item, i) => Object.assign(item, { handle: i }));
this.update({
items
});
Expand Down