diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index cbe059709d61e66277b2129714b3df9201eae243..7c99ce4f6fbfd87354b488f9eaf3bd2e9b881e21 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -53,6 +53,7 @@ export interface SelectManyParameters export interface TextInputParameters extends BaseInputParameters { readonly type: 'textInput'; readonly value?: string; + readonly valueSelection?: [number, number]; readonly prompt?: string; readonly validateInput?: (input: string) => TPromise; } @@ -124,6 +125,8 @@ class TextInputController implements InputController { this.result.then(() => this.dispose()); ui.inputBox.value = parameters.value || ''; + const selection = parameters.valueSelection; + ui.inputBox.select(selection && { start: selection[0], end: selection[1] }); ui.inputBox.setPlaceholder(parameters.placeHolder || ''); const defaultMessage = parameters.prompt ? localize('inputModeEntryDescription', "{0} (Press 'Enter' to confirm or 'Escape' to cancel)", parameters.prompt) @@ -374,6 +377,7 @@ export class QuickInputService extends Component implements IQuickInputService { return this.show({ type: 'textInput', value: options.value, + valueSelection: options.valueSelection, prompt: options.prompt, placeHolder: options.placeHolder, ignoreFocusLost: options.ignoreFocusLost, diff --git a/src/vs/workbench/browser/parts/quickinput/quickInputBox.ts b/src/vs/workbench/browser/parts/quickinput/quickInputBox.ts index 92e632c5fad51f4b3c25ab3bc6e144eaf7f5f4a0..3779d54c057f02c1242e94e0af3073b4f8fb855b 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInputBox.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInputBox.ts @@ -7,7 +7,7 @@ import 'vs/css!./quickInput'; import * as dom from 'vs/base/browser/dom'; -import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; +import { InputBox, IRange } from 'vs/base/browser/ui/inputbox/inputBox'; import { localize } from 'vs/nls'; import { inputBackground, inputForeground, inputBorder } from 'vs/platform/theme/common/colorRegistry'; import { ITheme } from 'vs/platform/theme/common/themeService'; @@ -58,6 +58,10 @@ export class QuickInputBox { this.inputBox.value = value; } + select(range: IRange = null): void { + this.inputBox.select(range); + } + setPlaceholder(placeholder: string) { this.inputBox.setPlaceHolder(placeholder); }