提交 87682505 编写于 作者: C Christof Marti

Implement valueSelection (#48116)

上级 d3cb5b21
......@@ -53,6 +53,7 @@ export interface SelectManyParameters<T extends IPickOpenEntry = IPickOpenEntry>
export interface TextInputParameters extends BaseInputParameters {
readonly type: 'textInput';
readonly value?: string;
readonly valueSelection?: [number, number];
readonly prompt?: string;
readonly validateInput?: (input: string) => TPromise<string>;
}
......@@ -124,6 +125,8 @@ class TextInputController implements InputController<string> {
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,
......
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册