Skip to content

Commit

Permalink
Implement password (#48116)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Apr 23, 2018
1 parent 8768250 commit a8633b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type InputParameters = SelectManyParameters | TextInputParameters;

export interface BaseInputParameters {
readonly type: 'selectMany' | 'textInput';
readonly placeHolder?: string;
readonly ignoreFocusLost?: boolean;
}

Expand All @@ -48,13 +47,16 @@ export interface SelectManyParameters<T extends IPickOpenEntry = IPickOpenEntry>
readonly picks: TPromise<T[]>;
readonly matchOnDescription?: boolean;
readonly matchOnDetail?: boolean;
readonly placeHolder?: string;
}

export interface TextInputParameters extends BaseInputParameters {
readonly type: 'textInput';
readonly value?: string;
readonly valueSelection?: [number, number];
readonly prompt?: string;
readonly placeHolder?: string;
readonly password?: boolean;
readonly validateInput?: (input: string) => TPromise<string>;
}

Expand Down Expand Up @@ -132,6 +134,7 @@ class TextInputController implements InputController<string> {
? localize('inputModeEntryDescription', "{0} (Press 'Enter' to confirm or 'Escape' to cancel)", parameters.prompt)
: localize('inputModeEntry', "Press 'Enter' to confirm your input or 'Escape' to cancel");
ui.message.textContent = defaultMessage;
ui.inputBox.setPassword(parameters.password);

if (parameters.validateInput) {
const onDidChange = debounceEvent(ui.inputBox.onDidChange, (last, cur) => cur, 100);
Expand Down Expand Up @@ -380,6 +383,7 @@ export class QuickInputService extends Component implements IQuickInputService {
valueSelection: options.valueSelection,
prompt: options.prompt,
placeHolder: options.placeHolder,
password: options.password,
ignoreFocusLost: options.ignoreFocusLost,
validateInput: options.validateInput,
}, token);
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class QuickInputBox {
this.inputBox.setPlaceHolder(placeholder);
}

setPassword(isPassword: boolean): void {
this.inputBox.inputElement.type = isPassword ? 'password' : 'text';
}

setFocus(): void {
this.inputBox.focus();
}
Expand Down

0 comments on commit a8633b2

Please sign in to comment.