Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
  • Loading branch information
JPinkney committed May 19, 2019
1 parent f192f49 commit 1827022
Show file tree
Hide file tree
Showing 7 changed files with 731 additions and 33 deletions.
56 changes: 53 additions & 3 deletions packages/core/src/browser/quick-open/quick-input-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,50 @@
********************************************************************************/

import { inject, injectable } from 'inversify';
import { QuickOpenService } from './quick-open-service';
import { QuickOpenService, TitleButton } from './quick-open-service';
import { QuickOpenItem, QuickOpenMode } from './quick-open-model';
import { Deferred } from '../../common/promise-util';
import { MaybePromise } from '../../common/types';
import { MessageType } from '../../common/message-service-protocol';
import { Emitter, Event } from '../../common/event';

export interface QuickInputOptions {

/**
* Show the progress indicator if true
*/
busy?: boolean

/**
* Allow user input
*/
enabled?: boolean;

/**
* Current step count
*/
step?: number | undefined

/**
* The title of the input
*/
title?: string | undefined

/**
* Total number of steps
*/
totalSteps?: number | undefined

/**
* Buttons that are displayed on the title panel
*/
buttons?: ReadonlyArray<TitleButton>

/**
* Text for when there is a problem with the current input value
*/
validationMessage?: string | undefined;

/**
* The prefill value.
*/
Expand Down Expand Up @@ -72,7 +108,7 @@ export class QuickInputService {
const validateInput = options && options.validateInput;
this.quickOpenService.open({
onType: async (lookFor, acceptor) => {
const error = validateInput ? await validateInput(lookFor) : undefined;
const error = validateInput && lookFor !== undefined ? await validateInput(lookFor) : undefined;
label = error || prompt;
if (error) {
this.quickOpenService.showDecoration(MessageType.Error);
Expand All @@ -97,7 +133,16 @@ export class QuickInputService {
placeholder: options.placeHolder,
password: options.password,
ignoreFocusOut: options.ignoreFocusOut,
onClose: () => result.resolve(undefined)
busy: options.busy,
buttons: options.buttons,
enabled: options.enabled,
step: options.step,
title: options.title,
totalSteps: options.totalSteps,
onClose: () => {
result.resolve(undefined);
this.onDidHideEmitter.fire(undefined);
}
});
return result.promise;
}
Expand All @@ -112,4 +157,9 @@ export class QuickInputService {
return this.onDidAcceptEmitter.event;
}

readonly onDidHideEmitter: Emitter<void> = new Emitter();
get onDidHide(): Event<void> {
return this.onDidHideEmitter.event;
}

}
27 changes: 27 additions & 0 deletions packages/core/src/browser/quick-open/quick-open-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
import { injectable } from 'inversify';
import { QuickOpenModel } from './quick-open-model';
import { MessageType } from '../../common/message-service-protocol';
import URI from '../../common/uri';

export enum TitleButtonLocation {
LEFT = 0,
RIGHT = 1
}

export interface TitleButton {
location: TitleButtonLocation;
iconPath: URI | { dark: URI, light: URI } | { id: string };
iconClass?: string;
tooltip?: string | undefined;
}

export type QuickOpenOptions = Partial<QuickOpenOptions.Resolved>;
export namespace QuickOpenOptions {
Expand All @@ -27,6 +40,13 @@ export namespace QuickOpenOptions {
enableSeparateSubstringMatching?: boolean
}
export interface Resolved {
readonly busy: boolean
readonly enabled: boolean;
readonly step: number | undefined
readonly title: string | undefined
readonly totalSteps: number | undefined
readonly buttons: ReadonlyArray<TitleButton>

readonly prefix: string;
readonly placeholder: string;
readonly ignoreFocusOut: boolean;
Expand Down Expand Up @@ -55,6 +75,13 @@ export namespace QuickOpenOptions {
onClose(canceled: boolean): void;
}
export const defaultOptions: Resolved = Object.freeze({
busy: false,
enabled: true,
step: undefined,
title: undefined,
totalSteps: undefined,
buttons: [],

prefix: '',
placeholder: '',
ignoreFocusOut: false,
Expand Down
Loading

0 comments on commit 1827022

Please sign in to comment.